0

I have a few forms that I need to be able to save emojis, and the emojis can be anywhere on a string.

I can't seem to get unicode sequences to display as emojis.

Currently, the forms call a javascript function that call a PHP page via ajax and there it's inserted in the database. I need to be able to insert it into the database as \🙈 or \🙈 instead of \ud83d\ude48.

The page meta is using charset=utf-8. The relevant columns in the database are using Character set utf8mb4 and Collation utf8mb4_unicode_ci.

2
  • \uXXXX escapes are only valid in JSON, and &#XXXX; entities are only valid in HTML or XML documents. Decode it properly to UTF-8, store it properly as UTF-8, and re-encode if necessary for a particular output method. stackoverflow.com/questions/279170/utf-8-all-the-way-through
    – Sammitch
    Commented Sep 28, 2020 at 21:50
  • Please go read How to Ask and minimal reproducible example. “Currently, the forms call a javascript function that call a PHP page via ajax” - you should show us what you are actually doing there, instead of giving us just a vague verbal description.
    – 04FS
    Commented Sep 29, 2020 at 8:57

1 Answer 1

0

I would suggest that your php server needs to use this utility with the JSON response.

$noEntities = html_entity_decode($JSON);

https://www.php.net/manual/en/function.html-entity-decode.php

Not the answer you're looking for? Browse other questions tagged or ask your own question.