Re: fgets() equivalent?
- From: "Norman Diamond" <ndiamond@xxxxxxxxxxxxxxxx>
- Date: Fri, 30 Nov 2007 10:26:39 +0900
"Ben Voigt [C++ MVP]" <rbv@xxxxxxxxxxxxx> wrote in message
news:OJghlbpMIHA.2376@xxxxxxxxxxxxxxxxxxxxxxx
"Norman Diamond" <ndiamond@xxxxxxxxxxxxxxxx> wrote in message["You" was "Pops" there.]
news:eZmVFaiMIHA.4684@xxxxxxxxxxxxxxxxxxxxxxx
In a tab delimited text file, a tab separates fields within a line, a tab
doesn't separate lines. Oddly this part of it doesn't confuse fgets()
and doesn't confuse Excel, so I'm not sure why it confused you.
Bare LF characters within a field don't confuse Excel but do confuse
Windows version of fgets(), confuse DotNet even worse, and confuse you.
Bare LF characters in Unix would be a non-issue and that's why my
previous posting didn't even discuss Unix. In Unix any LF character
would end a line, so tab delimited text files don't even work, and they
have nothing to do with raw and cooked.
The tab character is entirely distinct from an LF, so I see no reason that
Unix can't have tab delimited text files.
heading1\theading2\theading3\n
field1\tfield2\tfield3\n
and so on
Excel can write this:
row 1 cell 1 has 1 subline\tcell 2\nhas 3\nsublines\tcell 3 has\n2 sublines\tcell 4\r\n
row 2 cell 1\nhas 2 sublines\cell 2 has 1 subline\t\tcell 4 has 1 subline\r\n
and so on.
If you use Unix native newline \n markers then you can't distinguish the end
of a subline in a cell from the end of a full row.
Now let's suppose you copy a tab delimited file from Windows to Unix. Unix
will not natively distinguish bare \n from Microsoft newline \r\n pairs. If
you use fgets() in Unix then you can put it in a loop and watch for the \r.
But Windows itself is worse. If you use fgets() in Windows then you can't
even see the \r. In Windows you have to read byte by byte.
DotNet is even worse. But the solution is the same; you still have to read
byte by byte.
.
- Follow-Ups:
- Re: fgets() equivalent?
- From: Ben Voigt [C++ MVP]
- Re: fgets() equivalent?
- References:
- Re: fgets() equivalent?
- From: Norman Diamond
- Re: fgets() equivalent?
- From: Pops
- Re: fgets() equivalent?
- From: Norman Diamond
- Re: fgets() equivalent?
- From: Ben Voigt [C++ MVP]
- Re: fgets() equivalent?
- Prev by Date: Suddenly Display becomes darker and mouse and keyboard dont repsond anymore,...
- Next by Date: Re: CreateIoCompletionPort and negative # of threads?
- Previous by thread: Re: fgets() equivalent?
- Next by thread: Re: fgets() equivalent?
- Index(es):
Relevant Pages
|