0

I have the following response from one of the API I am using:

\ud83d\udc51 CODE :: davon top\n\ud83d\udc51 MATERIAL :: spandek rayon\n\ud83d\udc51 PRICE :: 70.000\n\nFIX ORDER langsung hubungi contact :\n\ud83d\udc49 LINE : hijabroom\n\ud83d\udc49 PIN BB : 28EFA80B\nRead mekanisme before order!\n\n

I wanted to store this inside mysql database, however when I see this in my database it is stored as:

? CODE :: davon top
? MATERIAL :: spandek rayon
? PRICE :: 70.000

FIX ORDER langsung hubungi contact :
? LINE : hijabroom
? PIN BB : 28EFA80B
Read mekanisme before order!

the table is set as the following configurations:

enter image description here

What am I doing wrong here?

adit
  • 32,574
  • 72
  • 229
  • 373
  • You're not necessarily doing anything wrong; the behavior you describe is the behavior we expect, because MySQL `utf8` characterset only supports characters in Basic Multilingual Plane, does not support supplementary characters. – spencer7593 Nov 04 '14 at 03:51
  • also related: http://stackoverflow.com/questions/9509668/iphone-emoticons-insert-into-mysql-but-become-blank-value/ – deceze Nov 04 '14 at 05:11

1 Answers1

0

MySQL utf8 characterset supports only BMP (Basic Multilingual Plane), code points U+0000 thru U+D7FF.

The unicode points you show (U+D83D and U+DC51) form a surrogate pair, used to encode a supplementary character. From the MySQL documentation regarding utf8 support:

No support for supplementary characters (BMP characters only).

Reference: http://dev.mysql.com/doc/refman/5.5/en/charset-unicode-utf8.html

(The reason you're getting the question mark is because that's the default character for code points that can't be translated.)


MySQL 5.5 introduced utf8mb4 characterset, which is capable of storing supplementary characters.

spencer7593
  • 106,611
  • 15
  • 112
  • 140