Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emoji on MySQL and PHP: why some symbol yes other not?

After reading all the topics about emoji on SO I'm bounded to ask for some help. Question seems to be almost the same: I got an iPhone App sending via PHP emoji to MySQL DB, I can see some symbol on records, as example "umbrella" and "cloud" but other not (angry face, smiling face, and other).

Why some yes and other not?

  • MySQL Collation: utf8mb_unicode_ci
  • Table collation: utf8mb_unicode_ci
  • Field, varchar, collation: utf8mb_unicode_ci

PHP setup:

    mysql_query("SET CHARACTER SET utf8mb4");
    mysql_query("SET NAMES utf8mb4");

The symbols not showed inside the record are shown as question mark "?"

like image 884
Fabrizio Avatar asked Apr 14 '12 12:04

Fabrizio


1 Answers

Some emoji are encoded using 3 bytes. If your computers supports emoji, here are the 3 byte emoji:

☺❤✨❕❔✊✌✋☝☀☔☁⛄⚡☎➿✂⚽⚾⛳♠♥♣♦〽☕⛪⛺⛲⛵✈⛽⚠♨1⃣2⃣3⃣4⃣5⃣6⃣7⃣8⃣9⃣0⃣#⃣⬆⬇⬅➡↗↖↘↙◀▶⏪⏩♿㊙㊗✳✴♈♉♊♋♌♍♎♏♐♑♒♓⛎⭕❌©®™

The rest are encoded using 4 bytes and will not work unless you update mysql to utf8mb4. It sounds like you did not fully upgrade to utf8mb4 in some way.

like image 55
Jake Avatar answered Oct 19 '22 23:10

Jake