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.

prosoitos
  • 6,679
  • 5
  • 27
  • 41
Allaris
  • 3
  • 1
  • `\uXXXX` escapes are only valid in JSON, and `XXX;` 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. https://stackoverflow.com/questions/279170/utf-8-all-the-way-through – Sammitch Sep 28 '20 at 21:50
  • Please go read [ask] and [mre]. _“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 Sep 29 '20 at 08:57

1 Answers1

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

vnetkc
  • 116
  • 9