2

I have written an XML file which is using the ISO-8859-15 encoding and most of the data within the feed is ran through htmlspecialchars().

I am then using simplyxml_load_string() to retrieve the contents of the XML file to use in my script. However, if I have any special characters (ie: é á ó) it comes out as "é á ó". The

How can I get my script to display the proper special accented characters?

m90
  • 11,434
  • 13
  • 62
  • 112
David
  • 16,246
  • 34
  • 103
  • 162

1 Answers1

3

You’re probably using a different character encoding for you output than the XML data is actually encoded.

According to your description, your XML data encoded with UTF-8 but your output is using ISO 8859-15. Because UTF-8 encodes the character é (U+00E9) with 0xC3A9 and that represents the two characters à and © respectively in ISO 8859-15.

So you either use UTF-8 for your output as well. Or you convert the data from UTF-8 to ISO 8859-15 using mb_convert_encoding.

Gumbo
  • 643,351
  • 109
  • 780
  • 844
  • 2
    Gumbo, I came upon your post nearly two years later, but it was really helpful to me since I had a similar problem, thanks! The solution I used is `htmlentities($string, ENT_QUOTES, 'UTF-8');` when printing my output from the SimpleXMLElement – North Krimsly Jun 13 '11 at 18:12