"Re: [xml] xmlParseDocument with a specified encoding"



Hi,

To anyone who cares:

I found a workaround for my problem by doing the following:

Since I work with Delphi, the DOMString is a WideString, encoded in 
UTF-16 (little-endian and *no* byte order mark); in order to parse a 
DOMString representation of a xml-document - regardless of its encoding 
declaration - I used "xmlCreatePushParserCtxt & xmlParseChunk" with an 
initial chunk of 0xff 0xfe and the first 2 bytes of the specified 
DOMString. Doing this libxml2 detects the constructed UTF-16LE encoding 
and switches encoding. It does not care for the encoding declaration. 
I'm happy that it works :-)

Daniel Veillard wrote:
On Wed, Oct 22, 2003 at 11:34:16AM +0200, Kasimier Buchcik wrote:

Hi,

Is it possible to have a document (as string) in UTF-16 but with an 
other encoding declared in the document prolog, that I can pass to
xmlCreateDocParserCtxt and parse with xmlParseDocument? I.e. can I force 
the parser to handle the document with a specified encoding? Or will the 
parser autodetect somehow the UTF-16 encoding of the passed string and 
don't care for the declaration in the prolog?
Any hints?


  try xmlCtxtReadMemory() and by specifying the encoding, this may work,

Daniel

Regards,

Kasimier




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]