Read file with accented characters ?

J. Landman Gay jacque at hyperactivesw.com
Wed May 24 13:10:36 EDT 2006


Zax wrote:
> Well, after more tests with different text files, it appears that my
> solution doesn't work in some cases :(
> 
> Does anybody have a better idea ?
> 
>> I tried this function but it returns wrong result with Rev 2.5.1
>>
>> So finally I will use the following process:
>>
>>     open file MyFile for binary read
>>     if the result <> "" then
>>     read from file MyFile  until EOF
>>     close file MyFile
>>     put the number of lines in it into NumOfLines
>>     open file MyFile for text read
>>     read from file MyFile until EOF
>>     close file MyFile
>>     if the number of lines in it <> NumOfLines then get IsoToMac(it)
>>

Try this function:

function lineEndings pFilePath
   if pFilePath = "" then
     answer file "Choose a file:"
     if it = "" then exit to top
     put it into pFilePath
   end if
   put url ("binfile:"&pFilePath) into tData
   if offset(numToChar(10)&numToChar(13),tData) > 0 then
     return "Windows"
   else if offset(numToChar(10),tData) > 0 then
     return "Unix"
   else if offset(numToChar(13),tData) > 0 then
     return "Mac"
   end if
   return "Unknown"
end lineEndings

I didn't test it very much, so see what you get.

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com



More information about the Use-livecode mailing list