SimpleXML 西里尔字母编码
这是我正在使用的 XML 文件类型:
<?xml version="1.0" encoding="UTF-8"?>
<ProductCatalog>
<ProductType>Дънни платки</ProductType>
<ProductType>Дънни платки 2</ProductType>
</ProductCatalog>
当我使用以下代码运行 PHP 文件时:
$pFile = new SimpleXMLElement('test.xml', null, true);
foreach ($pFile->ProductType as $pChild)
{
var_dump($pChild);
}
我得到以下结果:
object(SimpleXMLElement)#5 (1) { [0]=> string(40) "Дънна платка наÑтолна"
我在 XML 文件中尝试了不同的编码,但它不能很好地处理西里尔字母符号。
This is the type of XML file, which I am using:
<?xml version="1.0" encoding="UTF-8"?>
<ProductCatalog>
<ProductType>Дънни платки</ProductType>
<ProductType>Дънни платки 2</ProductType>
</ProductCatalog>
And when I run the PHP file with the following code:
$pFile = new SimpleXMLElement('test.xml', null, true);
foreach ($pFile->ProductType as $pChild)
{
var_dump($pChild);
}
I get the following results:
object(SimpleXMLElement)#5 (1) { [0]=> string(40) "Дънна платка наÑтолна"
I have tried different encodings in the XML file but it's not working well with Cyrillic symbols.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果在浏览器中切换字符编码(为 utf-8)会发生什么?
我的意思是,看起来像是输出问题。
What happens if you switch Character encoding (to utf-8) in browser?
I mean, looks like output issue.