Does mongo support emoji characters

1,907 views
Skip to first unread message

global apps

unread,
Oct 28, 2011, 1:50:35 AM10/28/11
to mongodb-user
I tried to insert utf-8 encoded emoji character into mongodb, it's a
smirking face icon, utf-8 code is : f0 9f 98 8f , when i retrieve it
from mongodb, it code turns to be: \ud83d\ude0f . Any ideas? Thanks a
lot.

Sam Millman

unread,
Oct 28, 2011, 9:19:58 AM10/28/11
to mongod...@googlegroups.com
Well that is because the driver, which you are using is obviously outputting and/or storing in unicode so when it asks to transfer one thing to another it detects utf8 and transfers it to unicode.

Which driver are you using?

Can you show us what it looks like in your collection?

Maybe some sample code?


--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.


global apps

unread,
Oct 28, 2011, 11:09:02 PM10/28/11
to mongod...@googlegroups.com
Thans Sam, I'm using PHP driver. 

Here is the sample code :

1. store
$emoji = $_POST["content"];

$db->test->insert( array("_id" => "id1", "content" => $emoji));

2. retrieve and output

$result = $db->test->findOne(array("_id" => "id1"));

echo json_encode($result);

Actually, i found it works well with ios4.x 's emoji keyboard, but if use ios5's emoji keyboard to input emoji characters, it always display the wrong character. 
Maybe it because ios4.x using Softbank's emoji encoding, but ios5 using UNIFIED emoji encoding. But why the emoji characters input by ios5 aren't correctly displayed in ios5, i've no idea.

Thanks,
Lin

2011/10/28 Sam Millman <sam.m...@gmail.com>

Sam Millman

unread,
Oct 31, 2011, 5:53:46 PM10/31/11
to mongod...@googlegroups.com
Can you not just convert unicode to utf8, do you even require it in utf8? Judging by the sounds of the keyboards I would say it would be better to accommodate for both rather than try and get both to work like one.

Most likely IOS does not display the chars right cos they are in unicode fashion, if you transfer them to utf8 once you dig them out of DB do they display right?

I dont actually use ios I am a Android guy so there might be a bit of guess work in my answer.
Reply all
Reply to author
Forward
0 new messages