unexpected FileStream behavior
Ned Konz
ned at bike-nomad.com
Thu Jun 6 14:52:19 UTC 2002
On Thursday 06 June 2002 07:15 am, I wrote:
> On Wednesday 05 June 2002 02:56 pm, Rob Whitfield wrote:
> > When I do a FileStream NextLine I get a line of text as expected
> > from my input file. However, when I read the next line using
> > NextLine I get an unexpected space in front of the line. Is this
> > expected? If so, how do I get around it?
>
> Are you sure it's a space and not another character (say a newline
> or something)?
Background: Squeak by default considers a CR (ascii 16r0D) to end a
line. So if your text ends lines with CR/LF (redundant, but
unfortunately common on MS-DOS-derived systems), you'll see the
second and subsequent lines starting with a LF character (ascii
16r0A).
Anyway, to answer the second part of your question, you could do one
of the following (assuming it's a newline that you see):
* use the CrLfFileStream instead of FileStream
* just discard the character manually (if you know that it's going to
be a LF):
line = stream nextLine.
stream next.
--
Ned Konz
http://bike-nomad.com
GPG key ID: BEEA7EFE
More information about the Squeak-dev
mailing list
|