Re: [xml] Nano HTTP: Text vs Binary (unportable code)
- From: Tanguy Fautre <tfautre dsimprove be>
- To: xml gnome org
- Subject: Re: [xml] Nano HTTP: Text vs Binary (unportable code)
- Date: Wed, 14 Apr 2004 11:13:27 +0200
On Wednesday 14 April 2004 01:08, Daniel Veillard wrote:
On Tue, Apr 13, 2004 at 02:56:01PM +0200, Tanguy Fautré wrote:
1) Unportable UNIX system calls are used for handling files. Why not use
FILE* which is the portable way to handle files in C?
Because Solaris was breaking due to a limited of FILE * allowed per
process.
That's bad... The Solaris C implementation must be really bad to allow more
file handlers via UNIX functions than via FILE*. But that's another topic...
2) As the symptoms suggest, the file is opened in default mode, which is
text mode.
Notice that under Linux there isn't really such a thing as a text mode,
because it's the same as the binary mode; which is why you can't specify
O_BINARY in open() under Linux (I don't see it in the man page, but I
could be wrong).
But under Windows, it's not the same and some characters get modified
(ex: '\n' becomes LineFeed + CarriageReturn, or something like that).
I though those portability problems had been solved years ago ...
Apparently not.
Do you mean solved in libxml or in Windows ?
So, shouldn't files be always saved in binary?
In the context of XML, yes I think so.
Concerning your example, it's C++, using the C++ I/O, I fail to see how
this relates to libxml2.
There are two programs in the attachment. The first one uses libxml2 to save
directly to the file, and this version doesn't work on Windows because of the
text vs binary issue.
The second one uses C++ I/O, but it's just an example to prove that when
saving to binary it works.
But of course in the example it's using a jpeg, so we know it's a binary file.
I'm not sure it would still work correctly with a text file.
P.S.: for further discussion, please subscribe to the list.
I am subscribed to the list (I'm getting the daily xml digest, so I suppose
the subscribtion works).
But for some reason, my emails get sometimes rejected ("The reason it is being
held: Message has a suspicious header"). I'm using KMail 1.5.4.
Regards,
Tanguy
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]