Platform Line Termination?

Bert Freudenberg bert at isgnw.CS.Uni-Magdeburg.De
Sun Feb 6 18:40:17 UTC 2000


On Sun, 6 Feb 2000, R. A. Harmon wrote:

> I'm re-visiting the problem I am having with reading and writing SIF files
> in a platform independent way.
> 
> I think the root of the problem is that when editing in browser window or a
> file's contents in a FileList (?), pasting text terminated with cr into a
> text terminated with crlf, or crlf into cr, will leave the resulting text
> with "mixed" line termination.

If it displays correctly, it has CRs in it.

> This is a bigger problem that I want to tackle now, but I think I can
> greatly mitigate it in my SIF files by manually terminating out going lines
> with the platform convention and incoming with cr.

Why don't you use CrLfFileStream?

When writing to a new file it creates it in the correct platform dependend
way. When writing to an old file, it tries to detect and preserve the
convention used. When reading, it converts all cr/lf stuff to cr.

If you still want to detect the platform, check
CrLfFileStream>>guessDefaultLineEndConvention. Or look which FileDirectory
subclass is active.

  -Bert-





More information about the Squeak-dev mailing list