|
![](/i/fill.gif) |
Ron Parker wrote:
> On Tue, 1 Feb 2000 20:33:49 -0500, Nathan Kopp wrote:
> >Not much different. Part of it is to use ftell twice to determine the
> >length of the macro. But the problem is that fread() reads a single byte
> >for CR+LF (converts two to '\n'), but ftell()-ftell() will give two bytes
> >for CR+LF. Unfortunately, this does not always happen and is not at all
> >consistent across operating systems or even compilers on the same OS.
>
> With all the problems CR/LF/CRLF cause us, why don't we just open the
> scene files in binary mode?
Probably because if you open a file as binary, you'd have to manage the
conversion of CRLF to LF yourself, whereas opening in text mode handles some
of it for you. Especially for DOS/Windows programmers, opening in text mode
to get CRLF converted to LF is quite handy. Hmmm... I wonder if on the Mac it
converts the simple CR to LF?
Anyway, I think that's why. But I think that the why-not would probably
outweigh the why. Of course, my personal preference would be to read and
normalize EOL's and also to Unicode (UTF-8 or UTF-16) and make sure the
reading routines were written to handle this. Perhaps step one would be to
get away from direct dependence on ftell and isolate that in a buffer layer
that opens files in binary mode and handles EOL conversions. Step two could
be to then make this layer return Unicode and to handle that properly.
Once that was done, the program could handle all sorts of languages without
having to actually process in those charsets. Also, that could make things
work for people who don't have that specific language as their OS. That is, a
Japanese user could send me a Japanese POV-Ray source file and even though I
would be unable to read it, I could render it and get the exact same results
as the Japanese user did.
But... opening files in binary mode and handling the CRLF issues (even the
messed up CRCRLF that you get on Windows) probably would be best.
--
"My new computer's got the clocks, it rocks
But it was obsolete before I opened the box" - W.A.Y.
Post a reply to this message
|
![](/i/fill.gif) |