• 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: Shane Stanley <email@hidden>
  • Date: Thu, 07 Aug 2014 09:42:49 +1000

On 7 Aug 2014, at 1:12 am, Gil Dawson <email@hidden> wrote:

> So, when I used TextEdit to create those three ".txt" files, each with a different encoding in the "Save As..." dialog...
>
> 	One to UTF-8
> 	One to Western (MacOS Roman)
> 	One to Western (Windows Latin 1)
>
> ...the three files were not "plain text" files, but each must have had had an extended attribute saved with it (somewhere).

Technically they are still "plain text" files, if there is such a thing -- they are identical. Extended attributes are not actually saved within the file. That's why they aren't always available.
>
> I was wondering is there any way to pick up this extended attribute from within ASObj-C.  Then I looked through the NSString class methods and I found:
> stringWithContentsOfFile:usedEncoding:error:

Just be aware that it's unreliable if the file in question does not have extended attributes. Again, trial-and-error is often safest. Start with UTF-8, because if a file is not UTF-8, and it uses more than ASCII characters, it is very, very unlikely to be able to read as UTF-8. So if UTF-8 fails, you can drop back to something else.

But there's no foolproof method.

--
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>


 _______________________________________________
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


  • Follow-Ups:
    • Re: Read a text file
      • From: Emmanuel LEVY <email@hidden>
References: 
 >Re: Read a text file (From: Shane Stanley <email@hidden>)
 >Re: Read a text file (From: Gil Dawson <email@hidden>)

  • Prev by Date: Re: Applescript AeroSnap
  • Next by Date: Re: Applescript AeroSnap
  • Previous by thread: Re: Read a text file
  • Next by thread: Re: Read a text file
  • Index(es):
    • Date
    • Thread