CR and LF in Text files

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
JRW
Reply | Threaded
Open this post in threaded view
|

CR and LF in Text files

JRW
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.
Reply | Threaded
Open this post in threaded view
|

Re: CR and LF in Text files

Michael Ross-1
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.