• 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: Read a text file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Read a text file


  • Subject: Re: Read a text file
  • From: Stan Cleveland <email@hidden>
  • Date: Wed, 30 Jul 2014 14:01:20 -0700

On Jul 30, 2014, at 12:05 PM, Gil Dawson wrote:

But can read srtFile diagnose encodings?

Hi Gil,

It can to some extent, but it depends on the file it's reading. These days, there are many ways by which a file may reveal its encoding (see http://en.wikipedia.org/wiki/File_format). More specific to text would be the byte order mark or BOM, if the file has one (see http://en.wikipedia.org/wiki/Byte_order_mark).

I've never found documentation of just exactly what rules are used by read file to determine encoding. But I'd guess that it checks first for a BOM, then defaults to UTF-8 otherwise.

If you know the format of the text file, you can instruct read file to utilize a specific UTF encoding:
set docLines to paragraphs of (read srtFile as «class utf8») -- reads as UTF-8
set docLines to paragraphs of (read srtFile as Unicode text) -- reads as UTF-16

HTH,
Stan C.

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Encrypt/Decrypt a Text File (From: Eric Geoffroy <email@hidden>)
 >Read a text file (From: Gil Dawson <email@hidden>)
 >Re: Read a text file (From: Gil Dawson <email@hidden>)

  • Prev by Date: Re: Read a text file
  • Next by Date: Re: Weird behavior of text in Pages
  • Previous by thread: Re: Read a text file
  • Next by thread: Re: Informal poll
  • Index(es):
    • Date
    • Thread