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?
Asked
Active
Viewed 4.1k times
23
-
1The 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
-
1http://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
1 Answers
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,221
- 5
- 37
- 59
-
-
2@Hector Checkout the Python [howto article](https://docs.python.org/2/howto/unicode.html). On a string you can use the encode() method: u.encode('utf-8') – binarysubstrate May 03 '14 at 21:17