50494

Emoji not saved correctly in mongodb

Question:

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.

Recommend

  • How to change utf-8mb4 to UTF-8 in groovy?
  • Changing MySQL charset to UTF8 on linux so it will work with JDBC
  • How do I check assembly output of Java code?
  • pandas parse csv with left and right quote chars
  • MongoError: getaddrinfo ENOTFOUND undefined undefined:27017
  • php DOMDocument - manipulating and encoding
  • C# Networkstream reads nothing
  • Return null in boolean to checkbox state converter in XAML
  • Azure table query partial partitionkey guid match
  • Xamarin PCLCrypto SHA256 give different hash
  • Install phpMongo Drivers on windows
  • custom string delimiters stringtemplate-4
  • How to extract text from a PDF and decode characters?
  • pymongo replication secondary readreference not work
  • SIP API media codecs
  • What is the use of a session store?
  • Does Apportable support to build library binary (.a/.so)?
  • Validate jQuery plugin, field not required
  • How can I include If-None-Match header in HttpRequestMessage
  • How to make JSON.NET deserialize to Microsoft Date Time?
  • Hardware Accelerated Image Scaling in windows using C++
  • Chrome doesn't support silverlight anymore? How to solve this?
  • Syntax for setting draggablecursor property in google maps api
  • Paperclip, set path outside of rails root folder
  • Encrypt data by using a public key in c# and decrypt data by using a private key in php
  • Why HTML5 Canvas with a larger size stretch a drawn line?
  • Spray.io: When (not) to use non-blocking route handling?
  • Modifying destination and filename of gulp-svg-sprite
  • SSO with signing and signature validation doesn't work
  • Deserializing XML into class C#
  • Can I make an Android app that runs a web view in Chrome 39?
  • When should I choose bucket sort over other sorting algorithms?
  • Timeout for blocking function call, i.e., how to stop waiting for user input after X seconds?
  • GridView Sorting works once only
  • InvalidAuthenticityToken between subdomains when logging in with Rails app
  • How to include full .NET prerequisite for Wix Burn installer
  • SQL merge duplicate rows and join values that are different
  • LevelDB C iterator
  • Can't mass-assign protected attributes when import data from csv file
  • costura.fody for a dll that references another dll