Read file with accented characters ?

Zax zax at tripoy.com
Tue May 23 03:04:03 EDT 2006


Thanks Devin for your solution.
I have to say I don't know how to check the line endings in a safe way :(
For exemple, I could write
------
    if (numToChar(13) & numToChar(10)) is in it then
      put "win" into fileFormat
    else if numToChar(10) is in it then
      put "nix" into fileFormat
    else put "mac" into fileFormat
------
but it's not very safe because ASCII 10 can sometimes be found in Mac
files...

> 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

----------------------
Zax 





More information about the use-livecode mailing list