Newbie Question

Martin Baxter mb.userev at harbourhosting.co.uk
Thu Mar 29 20:00:50 EDT 2007


J. Landman Gay wrote:
> Martin Baxter wrote:
> 
>> Last I checked (admittedly quite a while ago) this was not true on 
>> Linux, just on Mac and Win. perhaps this has changed?
>> Anybody currently working on Linux know if RR can nowadays properly 
>> open mac or win text files and translate line-endings without scripted 
>> assistance?
> 
> There are certain instances where line endings are not translated. For 
> example, if you open a file for binary read, or use the "binfile" form 
> of the URL container, the original endings remain the same. When you had 
> problems, were you using either of these methods?
> 

This is opening the files as text - i.e. using file:. With binfile: data 
is unaffected on any platform as expected.

I determined, by testing, that on Linux (and I would assume - other 
Unixes as well) there appears to be an assumption that any text files 
you import already have LF line endings, so no conversion is done. On 
Mac and Windows the native line endings (for either platform) are 
automagically translated.

The logic behind this seems to be that on Mac and Win the native text 
file line endings need converting to the internal format, but on Linux 
they don't, as native files already are LF terminated. I concluded that 
the fact that you can move text files between mac and win without 
worrying about line endings may be an accident of the implementation 
rather than a deliberate intention.

Since I was writing an app to run on Mac & Win & Linux at the time, I 
got around this by re-writing my file I/O to always use binfile: and to 
manage the line endings myself by script.

But this was a surprise when I discovered it. My text file data had to 
be portable between the different platform versions and I had assumed, 
on the basis of Mac and Win experience, that RR would take care of this 
in the same way in Linux (i.e. would convert win and mac files when 
importing them). But when I actually moved a project from Win to Linux 
it turned up full of unexpected ascii 13s, which is when I investigated 
this.

This was a couple of years back now I suppose, version 2.1.2 I think. I 
haven't tried newer versions of RR on Linux. So although I suspect it's 
still the same, I don't really know.

Martin



More information about the use-livecode mailing list