CR and LF in Text files

2 messages Options
Embed this post
Permalink
jowen

CR and LF in Text files

Reply Threaded More More options
Print post
Permalink
I have a simple list of items in a text file with "Enter" separating.  When I read them into a Set the first item in the list is picked up differently to later occurrences of the same thing.  Hence, one too many items in the "Set".  Inspecting shows that later items are proceeded by a linefeed character which is why they end up different to the Set than the first.  What am I doing wrong?  The same thing works fine in VisualWorks.  Thanks.
Michael Ross-1

Re: CR and LF in Text files

Reply Threaded More More options
Print post
Permalink
This sounds like a variation of the LineEnd problem.
There are three ways of separating lines in text files-

 CR used in Mac
 LF used in Unix
 CRLF used in Windows

Squeak chose CR as its standard. I would guess you are reading a file
made on a Windows platform. Find the method
  String>>withSqueakLineEndings
and see if you can apply it to your file's contents before making your Set.

-Michael

jowen wrote:
I have a simple list of items in a text file with "Enter" separating.  When I read them into a Set the first item in the list is picked up differently to later occurrences of the same thing.  Hence, one too many items in the "Set".  Inspecting shows that later items are proceeded by a linefeed character which is why they end up different to the Set than the first.  What am I doing wrong?  The same thing works fine in VisualWorks.  Thanks.