title: Photoshop saves copyright symbol as UTF-8 (unescaped) in metadata
body: <p>**Update - I found this <a href="http://www.openphotographyforums.com/forums/showthread.php?p=97681" rel="nofollow">post</a> regarding Photoshop's encoding - saying they "encode the character "©" into Exif metadata in UTF-8 encoding." </p>
  
  <p>** Answer - it was an escaping problem - not an encoding problem. Photoshop allows the copyright symbol in the metadata without escaping it. This is mentioned (and complained about) in the above link. I changed the title to reflect the real issue**</p>
  
  <p>I've read everything on this site trying to save copyright symbol to jpeg metadata. I know the issues are encoding and have tried everything. </p>
  
  <p>Problem:
  When I save a copyright symbol to jpeg metadata it shows as <code>&amp;#xa9;</code> in Photoshop, but when I load the metadata it comes in correctly.</p>
  
  <p>When writing to the jpeg, I am calling UTF8_to_unicode_array() to encode the string and then unicode_array_to_UTF8() before saving it. Any idea what I am missing?</p>
  
  <p>From UTF8 to unicode:</p>
  
  <pre><code>function UTF8_to_unicode_array($utf8_text )
  {    
      // Create an array to receive the unicode character numbers output
      $output = array();
      mb_convert_encoding($utf8_text,'utf-8');                
      $atext = mbStringToArray($utf8_text);
  
  // Cycle through the characters in the UTF-8 string
  foreach ($atext as $text ){
      $output [] = uniord2($text);
  }
  return $output;
  }
  
  function uniord2($c)
  
    $ord0 = ord($c{0}); if ($ord0&gt;=0   &amp;&amp; $ord0&lt;=127) return $ord0;
    $ord1 = ord($c{1}); if ($ord0&gt;=192 &amp;&amp; $ord0&lt;=223) return ($ord0-192)*64 + ($ord1-128); 
    $ord2 = ord($c{2}); if ($ord0&gt;=224 &amp;&amp; $ord0&lt;=239) return ($ord0-224)*4096 + ($ord1-128)*64 + ($ord2-128);
    $ord3 = ord($c{3}); if ($ord0&gt;=240 &amp;&amp; $ord0&lt;=247) return ($ord0-240)*262144 + ($ord1-128)*4096 + ($ord2-128)*64 + ($ord3-128);
  return false;
  }
  
  
  function mbStringToArray ($string) {
    $array = array();
    $strlen = mb_strlen($string);
    while ($strlen) {
      $array[] = mb_substr($string,0,1,"UTF-8");
      $string = mb_substr($string,1,$strlen,"UTF-8");
      $strlen = mb_strlen($string);
  }
  return $array;
  }
  </code></pre>
  
  <p>From unicode to UTF8:</p>
  
  <pre><code>function unicode_array_to_UTF8( $unicode_array ){
      // Create a string to receive the UTF-8 output
      $output = "";
  
      // Cycle through each Unicode character number
      foreach( $unicode_array as $unicode_char )
      {
    $output .= utf8($unicode_char);
  }
  
      // Return resulting UTF-8 String
      return $output;
  }
  
  function utf8($num){
    if($num&lt;=0x7F)       return chr($num);        
    if($num&lt;=0x7FF)      return chr(($num&gt;&gt;6)+192).chr(($num&amp;63)+128);
    if($num&lt;=0xFFFF)     return chr(($num&gt;&gt;12)+224).chr((($num&gt;&gt;6)&amp;63)+128).chr(($num&amp;63)+128);
    if($num&lt;=0x1FFFFF)   return chr(($num&gt;&gt;18)+240).chr((($num&gt;&gt;12)&amp;63)+128).chr((($num&gt;&gt;6)&amp;63)+128).chr(($num&amp;63)+128);
  return '';
  }
  </code></pre>