Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't I use Ñ in my XML output, when declared as UTF-8?

I have the 'N Tilde' character Ñ in my Z/OS DB2 database. I am generating an xml file from the data. In the XML I have encoding=UTF-8, however Internet Explorer gives me the error Illegal character in text field. If I change the encoding to ISO-8859-1 it works fine.

I thought ISO-8859-1 was a subset of UTF-8, so why is it not working with UTF-8?

Is UTF-8 the best for an XML document?

like image 965
Tim Avatar asked Dec 16 '22 17:12

Tim


1 Answers

ISO-8859-1 is not a subset of UTF-8. It can represent a subset of the characters representable in UTF-8, but it doesn't do so in the same way.

Both ISO-8859-1 and UTF-8 are supersets of ASCII (i.e. they can represent all characters that ASCII can represent and they represent them in the same way).

So you can't just label ISO-8859-1 data as UTF-8 and hope that it works, you need to actually store (or convert) your data as UTF-8.

like image 170
Joachim Sauer Avatar answered Dec 19 '22 11:12

Joachim Sauer