[yunqa.de] Re: In DIXml this is a bug about encoding?

  • From: Delphi Inspiration <delphi@xxxxxxxx>
  • To: yunqa@xxxxxxxxxxxxx,yunqa@xxxxxxxxxxxxx
  • Date: Sat, 22 Aug 2009 11:43:59 +0200

At 11:33 20.08.2009, w w wrote:

>          cur := XPathObj^.NodeSetVal^.NodeTab[i];
>          WriteLn('= element node ', cur^.Name);
>          writeln('node value:',ansistring(cur^.Content));
>if cur^.Content have chinese char,the output is unreadable codes; 

cur^.Name and cur^.Content are always UTF-8 encoded, regardless if the document 
input character encoding is Chinese or any other encoding.

Therefore you should convert this UTF-8 back to UTF-16 or your favourite 
encoding. Example:

  cur := Nodes^.NodeTab[i];
  WriteLn('= element node ', Utf8Decode(cur^.Name));
  WriteLn('node value:', (Utf8Decode(cur^.Content)));


Delphi Inspiration mailing list

Other related posts: