jayem
jayem

Reputation: 229

PHP XMLReader Special Characters

I am using XMLReader, more specifically, Jeremy Johnstone's plist processer to process a plist XML file. Some of the strings in the XML file contain special characters. One example is "Frédéric Chopin". When I try to print strings with special characters, they are not being displayed correctly. For example, "Frédéric Chopin" is shown as "Frédéric Chopin" instead.

What can I do so the string is displayed as "Frédéric Chopin"? Thanks!

Upvotes: 0

Views: 1275

Answers (2)

Álvaro González
Álvaro González

Reputation: 146340

That looks like a UTF-8 string misinterpreted as some other encoding. You can use iconv() or mb_convert_encoding() to convert into whatever your site uses. I recommend the second one since it can generate HTML entities:

<?php
echo mb_convert_encoding($input, 'HTML-ENTITIES', 'UTF-8');

Upvotes: 2

Jason McCreary
Jason McCreary

Reputation: 72961

This has to do with the encoding. Be sure the display encoding matches the XML encoding, (e.g. UTF-8). I am not familiar with that plist processor, but it is possible you may have to set the encoding for the parser as well.

Upvotes: 0

Related Questions