我们使用MongoDB和PHP来处理来自PayPal的IPN。 问题是我们有来自俄罗斯的许多客户,并尽可能地尝试,我无法让MongoDB正确存储数据。
例如,我们有一个名为Юлия的客户,其俄语地址具有类似的格式化字符。 如果我直接在PHP中打印它,它会正确显示但是如果我将它放入MongoDB并回拨它我只是得到ЮлиÑ
我尝试了各种编码,但每次MongoDB似乎都返回了错误的文本。 我应该如何格式化文本以在MongoDB中存储这些字符并能够检索它们? 我是否需要将它们转换为一种格式进行存储,然后再将它们转换回来进行显示?
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?
最满意答案
Mongo将所有字符串存储为utf-8,并期望它们按原样传送。 只需将数据转换为utf-8,然后再将其发送到mongo即可。
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.
更多推荐
发布评论