• 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: Odd File Write Issue
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Odd File Write Issue


  • Subject: Re: Odd File Write Issue
  • From: Christopher Nebel <email@hidden>
  • Date: Sun, 13 Dec 2009 21:03:26 -0800

Emmanuel's explanation was basically correct.  Bear in mind that whether a text object is of class "string" or class "Unicode text" is a matter of where it came from and how you've been handling it, not its contents -- a Unicode text object may still contain nothing but ASCII characters.  Many commands and applications return Unicode text in 10.4, such as the "text returned" parameter of "display dialog".

Unless you say otherwise using "as ...", "write" in 10.4 and earlier will write out Unicode text objects using UTF-16, as Emmanuel said.  In 10.5 and later, the encoding is determined purely by the "as" parameter: no "as", "as string", or "as text" will use the primary encoding (to you, probably MacRoman), "as Unicode text" will use UTF-16, and "as «class utf8»" will use UTF-8.  This is all documented in the AppleScript Language Guide.


--Chris Nebel
AppleScript Engineering

On Dec 6, 2009, at 5:04 PM, andy knasinski wrote:

> Thanks for the tip. My string was just a plain string (I believe) and not unicode text.
>
> The dictionary entry, below, didn't provide much help. I always assumed if you wrote a string it was as text. I will adjust to try UTF8.
>
> [as type class] : how to write the data: as text, data, list, etc.
>
>
> On Dec 6, 2009, at 7:06 AM, email@hidden wrote:
>
>> Well-known issue, andy. At some point (maybe that was Tiger), "write
>> this_data to the open_target_file" would (provided this_data is
>> Uniocde, which is very frequent, many apps talk Unicode) make a UTF-16
>> file (it used to produce Macintosh-encoded files before). UTF-16 is a
>> Unicode file format where our character set is rendered on two bytes,
>> one of them being 0.
>>
>> I think that, to make Macintosh encoded files, you have to say
>> "write ... as string" and to make UTF-8 files (where our character set
>> is rendered mostly like ISO-8859) you says as «class utf8».
>>
>> Maybe that's documented in the "write" entry in Standard Additions'
>> AppleScript dictionary.

 _______________________________________________
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: 
 >Re: Odd File Write Issue (From: andy knasinski <email@hidden>)

  • Prev by Date: Re: How do I pause a script to allow a webpage to load and then resume the script?
  • Next by Date: RE : Modified "modification date" [Solved... almost]
  • Previous by thread: Re: Odd File Write Issue
  • Next by thread: Is it possible to multi-thread do shell script?
  • Index(es):
    • Date
    • Thread