简体   繁体   English

PHP和XML融合,正确编码特殊字符

[英]PHP and XML fusion, correctly encoding special characters

I've got a database that outputs a great deal of information. 我有一个输出大量信息的数据库。 I'm currently building a PHP application to build this database into an XML format for another application to read. 我目前正在构建一个PHP应用程序,将此数据库构建为XML格式,供另一个应用程序读取。

I'm a little stuck with special characters. 我有点陷入特殊角色。
In the database, some characters are printing strangely: 在数据库中,一些字符打印奇怪:

Ø becomes Ø Ø变成Ã〜
° becomes ° °变为°

I'm using fwrite() to write the XML file in the PHP and I think the error resides there somehow. 我正在使用fwrite()在PHP中编写XML文件,我认为错误存在于某种程度上。

I need a way to overcome this, perhaps by detecting where an occurrance of these characters occur and replacing them appropriately. 我需要一种方法来克服这个问题,可能是通过检测这些字符的出现位置并适当地替换它们。

I'm using PHP and I'm not sure how to replace these characters on an individual basis, and more importantly, I'm not sure what to replace them with! 我正在使用PHP而且我不确定如何在个人基础上更换这些字符,更重要的是,我不知道如何替换它们!

Can someone help? 有人可以帮忙吗?

Ø becomes Ø , ° becomes ° Ø变为Ø°变为°

Looks like that UTF-8 encoded characters are passed to some display device and it's told the display device that those are ISO-8859-X or Windows-125X encoded characters. 看起来UTF-8编码的字符被传递到某个显示设备,它告诉显示设备那些是ISO-8859-X或Windows-125X编码的字符。

Tell the display device that this is indeed UTF-8 (which is by default the standard encoding for XML). 告诉显示设备这确实是UTF-8(默认情况下是XML的标准编码)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM