I am saving emoji from twitter and instagram into my mongodb database. But when i display the pulled data from the database. The emoji appear broken like this ❤️����������☀️��
Is there something i need to do different during saving data to mongodb, i am new to mongodb. I have read the emoji's use utf8-mb4 encoding but mongodb support only UTF8.Answer1:
UTF8 is the default encoding supported by MongoDB and support all characters (variable byte length) including utf8-mb4 (see below for further details). You are probably not converting your data to UTF-8 before uploading it to MongoDB or you are not treating the data as UTF-8 when retrieving the data.
Just to clarify, the original implementation "utf8" by MySQL was only for up to 3 bytes whereas the MySQL implementation called 'utf8-mb4' is actually up to 4 bytes long (like the official RFC recommends it).So utf8-mb4 in MySQL is the same as UTF8 in MongoDB.