Recent

Author Topic: xml read  (Read 3388 times)

radiio

  • New Member
  • *
  • Posts: 12
xml read
« on: March 24, 2017, 11:52:33 pm »
Hi,
you know me advice on how to load xml file encoding windows-1250

using the DOM library is not a problem to load UTF-8. But using a different coding is a mistake.

macrillo

  • New Member
  • *
  • Posts: 18
Re: xml read
« Reply #1 on: March 25, 2017, 02:23:35 pm »
I don't understand your question,( please be more specific ),
but from what I can tell you must use the same encoding,
ie if input is UTF-8,  you must make sure that your processing
 also take place using UTF-8 as input! Mabye you need to convert first
from utf-8 to another NameSpace ? ( utf-16 (wideschar) .. not really sure it exists )

radiio

  • New Member
  • *
  • Posts: 12
Re: xml read
« Reply #2 on: March 25, 2017, 04:58:21 pm »
I use DOM library and XMLRead.

I have an XML file that is encoded in windows = 1250th
When you are loading this file, the compiler will throw an error like that encoding 1250 is not supported.

fred

  • Full Member
  • ***
  • Posts: 201
Re: xml read
« Reply #3 on: March 26, 2017, 09:48:11 am »
Perhaps you could read the file, use CP1250ToUtf8 and write it to a stream and load it from there?

wp

  • Hero Member
  • *****
  • Posts: 11856
Re: xml read
« Reply #4 on: March 26, 2017, 10:59:11 am »
Following code from xmlread.pas shows that, besides "UTF-8", "UTF-16" and "UNICODE", the xmlreader seems to accept only these identifiers for the "encoding" attribute:
Code: Pascal  [Select][+][-]
  1. function Is_8859_1(const AEncoding: string): Boolean;
  2. begin
  3.   Result := SameText(AEncoding, 'ISO-8859-1') or
  4.             SameText(AEncoding, 'ISO_8859-1') or
  5.             SameText(AEncoding, 'latin1') or
  6.             SameText(AEncoding, 'iso-ir-100') or
  7.             SameText(AEncoding, 'l1') or
  8.             SameText(AEncoding, 'IBM819') or
  9.             SameText(AEncoding, 'CP819') or
  10.             SameText(AEncoding, 'csISOLatin1') or
  11. // This one is not in character-sets.txt, but was used in FPC documentation,
  12. // and still being used in fcl-registry package
  13.             SameText(AEncoding, 'ISO8859-1');
  14. end;

Therefore, make sure that the "encoding" attribute has one of these values. If you miss some of the special characters of this encoding do what freds proposed. But note that for reading utf8 you must "use" the unit laz2_xmlread instead of xmlread.

radiio

  • New Member
  • *
  • Posts: 12
Re: xml read
« Reply #5 on: March 26, 2017, 03:42:06 pm »
Thank you helped me    :)

 

TinyPortal © 2005-2018