I have a database that stores the names of video games with Unicode characters, but I cannot figure out how to correctly escape these Unicode characters when printing them in HTML response.
For example, when I print all games named Uncharted, I get the following:
Uncharted: Drake Fortuneâ„¢ Uncharted 2: Among Thievesâ„¢ Uncharted 3: Drake Deceptionâ„¢
but it should display this:
Uncharted: Drake Fortune™ Uncharted 2: Among Thieves™ Uncharted 3: Drake Deception™
I ran a quick javascript escape function to see which Unicode character ™ has, and found that it \u2122 .
I have no problem fully escaping every character in the string if I can correctly display the ™ character. My guess is to somehow find the hexadecimal representation of each character in a string and have PHP displaying Unicode characters as follows:
print "™";
I ask you to advise the best approach for Unicode, avoiding the line for friendly HTML. I did something similar for JavaScript, but JavaScript has a built-in function for escape and unescape.
I do not know any PHP functions of a similar function. I read about ord , but it just returns the ASCII character code for the given character, so the ™ or ™ . I would like this feature to be versatile enough to apply to any string containing valid Unicode characters.
source share