Re: [xml] newline in xmlTextWriter on win32



On 11/08/04 00:47, Michael Culbertson wrote:
Hello,

  I'm having difficulty with newlines ("\n") using xmlTextWriter on
Windows.  Instead of writing CRLF to the given output file as is the
windows convention, the text writer is outputting LF (\x0A) alone.  This
happens both when the newline is inserted due to automatic indentation and
when the newline is explicit in an inserted string constant (using
xmlTextWriterWriteFormatString).  I verified that newlines outputed using
fprintf and fwrite to regular files do indeed translate \n into CRLF.  I
poked around very briefly in the libxml2 code, but nothing jumped out at
me as a possible cause.  Does anyohe have an idea as to what could be
causing this problem?

Some details about my setup:
  - Cross-compiling for win32 on Debian GNU/Linux using mingw32-based gcc
        version 3.4.0
  - Using libxml2 version 2.6.10, self-compiled
  - On the windows side, running Win98
  - Text writer created using xmlNewTextWriterFilename()
  - I have tried default encoding (UTF-8?), ISO-8859-1, and plain ASCII

This conversion done by the C runtime has been deactivated in libxml on purpose. The problem was that under some bizarre conditions, xmlParseFile() followed by a xmlSaveFile() modified the data. It replaced every \n with \r\n, even if it allready was a \r\n, ending up with \r\r\n. One did the read-write again and it became \r\r\r\n.

This behaviour was not desirable, so libxml views XML files as binary not doing any translations. This makes the libxml output bytewise equal to that on Unix.

I guess, if you want a \r\n, you will have to specify \r\n.

Ciao,
Igor



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