Reputation: 11
In Delphi 10 Rio, I use IXMLDocument
to parse an XML file.
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?><AWXML><ACTION>RECUP<RETOUR>OK</RETOUR><CRITERE><COMPTE></COMPTE><REGROUPEME></REGROUPEME><bas01></bas01></CRITERE><RUBRIQUE><DOC_NOM>TEST110 €</DOC_NOM>
When I do
NomDoc := Node2.ChildNodes['DOC_NOM'].Text;
NomDoc
is 'TEST110 ?'
, but it should be 'TEST110 €'
.
Why is this happening, and how do I fix it?
Upvotes: 1
Views: 366
Reputation: 596206
The Encoding
attribute in the XML's prolog specifies the byte encoding of the XML itself, not the charset that the XML's content is to be interpreted in. XML content is always interpreted in Unicode only. Thus €
represents Unicode codepoint U+0080, which is a C1 control character that is "only valid in certain contexts in XML 1.0 documents, and whose usage is restricted and highly discouraged."
If you want to use a Euro character, Unicode codepoint U+20AC, in an XML document, you must use either €
or €
instead, regardless of the Encoding
specified.
Upvotes: 1