开发者

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?开发者_如何学C Do I need to convert them to one format for storage and then convert them back again for display?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜