title: Print Unicode characters PHP
body: <p>I have a database which stores video game names with Unicode characters but I can't figure out how to properly escape these Unicode characters when printing them to an HTML response. </p>
  
  <p>For instance, when I print all games with the name like Uncharted, I get this:</p>
  
  <pre><code>Uncharted: Drake's Fortuneâ„¢
  Uncharted 2: Among Thievesâ„¢
  Uncharted 3: Drake's Deceptionâ„¢
  </code></pre>
  
  <p>but it should display this:</p>
  
  <pre><code>Uncharted: Drake's Fortune™
  Uncharted 2: Among Thieves™
  Uncharted 3: Drake's Deception™
  </code></pre>
  
  <p>I ran a quick JavaScript escape function to see which Unicode character the <code>™</code> is and found that it's <code>\u2122</code>. </p>
  
  <p>I don't have a problem fully escaping every character in the string if I can get the <code>™</code> character to display correctly. My guess is to somehow find the hex representation of each character in the string and have PHP render the Unicode characters like this:</p>
  
  <pre><code>print "&amp;#x2122";
  </code></pre>
  
  <p>Please guide me through the best approach for Unicode escaping a string for being HTML friendly. I've done something similar for JavaScript a while back, but JavaScript has a built in function for escape and unescape. </p>
  
  <p>I'm not aware of any PHP functions of similar functionality however. I have read about the <a href="http://php.net/manual/en/function.ord.php" rel="noreferrer">ord</a> function, but it just returns the ASCII character code for a given character, hence the improper display of the <code>&amp;#x2122;</code> or the <code>&amp;trade;</code>. I would like this function to be versatile enough to apply to any string containing valid Unicode characters.</p>