简体   繁体   中英

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.

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.

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!

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.

Tell the display device that this is indeed UTF-8 (which is by default the standard encoding for XML).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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