23

I'm new to mongodb. I need to store some data in utf8 encoding in my DB. When I export them or see them into console, they don't display correctly. Can I set my database to utf8 character set to solve this problems? If yes, how can I do this?

Community
  • 1
  • 1
zorro6064
  • 484
  • 2
  • 7
  • 18
  • 1
    The charset is utf8 by default, most likely your PuTTY console (or whatever your using) is not reading utf8 correctly – Sammaye Jan 16 '13 at 10:52
  • how do you upload your data to mongodb? – joscas Jan 16 '13 at 11:03
  • 1
    http://stackoverflow.com/questions/4905074/how-do-i-configure-my-mongodb-to-take-utf-8-into-account/4905462#4905462 – WiredPrairie Jan 16 '13 at 11:03
  • If you are uisng putty (or infact I think this applies to most temrinals in one way or another) try clicking on the top left hand icon then going to "Change Settings" and then, in putty (if that is the case, this will be different for others) go to "Translation" then in the first drop down select UTF8 instead of ISO for remote encoding. See if that helps – Sammaye Jan 16 '13 at 11:24

2 Answers2

14

BSON can only be encoded in UTF-8. If your problem is with export and console, you probably are not converting your data to UTF-8 before uploading it to mongodb.

joscas
  • 7,474
  • 5
  • 39
  • 59
0

It is utf-8 by default in mongodb (see this thread in the mongo community forum). Perhaps your mongosh is set to a different encoding table, which you can check in its properties. Please note that even if data are not displayed as utf-8 in mongosh, it does not mean that they are stored with an incorrect encoding in the database (mongodb). To check that, copy-paste the characters from mongosh to a text file or somewhere else to see if they are rendered as utf-8.

Stefano
  • 85
  • 4
  • 10