Having trouble getting foreign characters and Emoji to display.
Edited to clarify
A user types an Emoji character into a text field which is then sent to the server (php) and saved into the database (mysql). When displaying the text we grab a JSON encoded string from the server, which is parsed and displayed on the client side.
QUESTION: the character for a “trophy” emoji saved in the DB reads as
%uD83C%uDFC6
When that is sent back to the client we don’t see the emoji picture, we actually see the raw encoded text.
How would we get the client side to read that text as an emoji character and display the image?
(all on an iphone / mobile safari)
Thanks!
Then your data are already mangled.
%uescapes are specific to the JavaScriptescape()function, which should generally never be used. Make sure your textarea->PHP handling uses standards-compliant encoding, egencodeURIComponentif you need to get a JS variable into a URL query.Then, having proper raw UTF-8 strings in your PHP layer, you can worry about getting MySQL to store characters like the emoji that are outside of the Basic Multilingual Plane. Best way is columns with a
utf8mb4collation; if that is not available try binary columns which will allow you to store any byte sequence (treating it as UTF-8 when it comes back out). That way, however, you won’t get case-insensitive comparisons.