Read file with accented characters ?

Devin Asay devin_asay at byu.edu
Mon May 22 12:54:35 EDT 2006


On May 22, 2006, at 1:29 AM, Zax wrote:

> Hello Jan,
> Tahnks for your help.
>
> I tried the ISOToMac() function and it works well with BBEdit files  
> saved in
> Unix/Win format... but it also converts standard Mac text files :(
>
> So is there a way to know how the text file was encoded before  
> applied the
> ISOToMac function ?
> Something like:
>
> open file myTextFile for read
> read from file until EOF
> If RevolutionTellsItsWinEncoded(it) then
>     get ISOToMac(it)
> else
>     -- do nothing, don't translaste it
> end

Zax,

The first thing that comes to mind is to check the line ending  
characters of the text file somehow. If lines end in LF (ascii 10)  
the file is *nix; if they end in CR (ascii 13) they are Mac; and if  
they end in CR+LF (ascii 13 + ascii 10) they are DOS/Windows. See the  
dictionary for the return, lf and cr constants for more information.

Devin


Devin Asay
Humanities Technology and Research Support Center
Brigham Young University




More information about the use-livecode mailing list