Most iOS emojis use code points above the Basic Multilingual Plane of the Unicode table. For example, 😄 (SMILING FACE WITH OPEN MOUTH AND SMILING EYES) is at U+1F604.
Now, see http://dev.mysql.com/doc/refman/5.5/en/charset-unicode.html.
MySQL before version 5.5 only supports UTF-8 for the BMP, which includes characters between U+0000 and U+FFFF (i.e. only a subset of actual UTF-8; MySQL’s utf8
is not real UTF-8). It cannot store the character at code point U+1F604 or other similar “high characters”. MySQL 5.5+ supports utf8mb4
(actual UTF-8), utf16
and utf32
, which are able to encode these characters. If you’re using MySQL 5.5+, use one of these column character sets and make sure you’re using the same charset for your connection encoding to/from PHP. If you are on MySQL < 5.5, you’ll have to use a BLOB
column type. That type stores raw bytes without caring about the “characters” in it. The downside is that you won’t be able to efficiently search or index the text.