MongoDB / PHP不喜欢俄语字符(MongoDB/PHP doesn't like Russian characters)

编程入门 行业动态 更新时间:2024-10-23 21:33:51
MongoDB / PHP不喜欢俄语字符(MongoDB/PHP doesn't like Russian characters)

我们使用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.

更多推荐

本文发布于:2023-08-05 16:51:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1437402.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:俄语   不喜欢   字符   PHP   MongoDB

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!