• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Reading file containing UTF-8
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reading file containing UTF-8


  • Subject: Re: Reading file containing UTF-8
  • From: julifos <email@hidden>
  • Date: Wed, 05 Nov 2003 20:39:47 +0100

>> I think these two will do the job:
>>
>> do shell script "cat ~/whatever/file.txt"
>>
>> read alias "path:to:file.txt" as <<class utf8>>
>
> Thanks for the reply jj. That does work, right up until I add until
> linefeed9, then it returns Unicode text but doesn9t recognise the UTF-8
> sequences:
>
> property somefile : alias ((path to desktop as text) & "Temporary Find List6
> copy.txt")
> property linefeed : ASCII character 10 -- Unix
>
> set a to (read somefile until linefeed) as <<class utf8>>
>
> log class of a
>
> I need the read the file in chunks (line by line) because it9s going to be 15
> Megs or so.

Hmmm... Seems that such code works fine here... Are you sure that LF is in
contents of such file? (well, most probably you are)

You can try instead reading the file in chunks. Eg:

repeat with i from 1 to contentsLength by 50000
try
read xfile from i to (i+50000)
on error
read xfile from i to -1
end try
end repeat

jj
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Bug reading file as UTF-8? [Was: Reading file containing UTF-8]
      • From: Tom Robinson <email@hidden>
  • Prev by Date: Re: Index to XML
  • Next by Date: Re: Newbie Stumbles
  • Previous by thread: Re: Reading file containing UTF-8
  • Next by thread: Bug reading file as UTF-8? [Was: Reading file containing UTF-8]
  • Index(es):
    • Date
    • Thread