Blank
Blank

Reputation: 4695

MongoDB/PHP doesn't like Russian characters

We're using MongoDB and PHP to handle IPNs from PayPal. The problem is we've had a number of customers from Russia and, try as I might, I can't get MongoDB to store the data correctly.

For example, we had a customer called Юлия with a Russian address with similar formatted characters. If I print this out directly in PHP it displays correctly but if I put it into MongoDB and call it back I just get ЮлиÑ

I've tried various encodings but every time MongoDB seems to return the wrong text. How should I format the text to store these characters in MongoDB and be able to retrieve them? Do I need to convert them to one format for storage and then convert them back again for display?

Upvotes: 5

Views: 1829

Answers (1)

Remon van Vliet
Remon van Vliet

Reputation: 18595

Mongo stores all strings as utf-8 and expects them to be delivered as such. Simply convert your data to utf-8 before sending it to mongo and you're set.

Upvotes: 5

Related Questions