simplexml_load_string() doesn't like foreign languages

≯℡__Kan透↙ 提交于 2019-12-18 09:19:15

问题


I am receiving an XML response which comes through perfectly.

Words such as "português" and "españa" are correctly formatted.

However, once I have parsed the XML through the php function simplexml_load_string(), the words are transformed as follows: "portugu�s" and "espa�a".


回答1:


Simple XML always treats text internally as UTF-8 encoded, converting to and from this character set if necessary. To solve your issue either make sure that all output from your app is UTF-8 encoded or convert it to another character set (possibly using utf8decode()).



来源:https://stackoverflow.com/questions/5943555/simplexml-load-string-doesnt-like-foreign-languages

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!