• 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: Write a file in utf8
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Write a file in utf8


  • Subject: Re: Write a file in utf8
  • From: "Mark J. Reed" <email@hidden>
  • Date: Wed, 5 Aug 2009 09:07:08 -0400

On Wed, Aug 5, 2009 at 8:57 AM, Yvan KOENIG<email@hidden> wrote:
>                write (ASCII character 254) & (ASCII character 255) to
> the_file starting at 1
>                write (FileContent as «class utf8») to the_file starting at 3

Uhm, what?  Why are you writing a UTF-16 BOM and then writing UTF-8
content?  That's just lying to whatever reads the file later.

(Assuming the above even works  - will the two "write (ASCII
character)" commands  each write a single byte, or will they each
write a two-byte UTF-16 character?)

If you really want to include a BOM - which you don't need in UTF-8 -
it needs to be a UTF-8 BOM.  That is, the character U+FEFF in UTF-8
form.  That happens to be the three bytes 0xef, 0xbb, 0xbf (239, 187,
191 decimal), but you're better off just prepending the BOM character
before the UTF-8 encoding (at least on Leopard):

write (((character id 65279) & FileContent) as «class utf8») to
the_file starting at 1


--
Mark J. Reed <email@hidden>
 _______________________________________________
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: 
 >Write a file in utf8 (From: Jay Louvion <email@hidden>)
 >Re: Write a file in utf8 (From: Yvan KOENIG <email@hidden>)

  • Prev by Date: Re: Write a file in utf8
  • Next by Date: Re: Write a file in utf8
  • Previous by thread: Re: Write a file in utf8
  • Next by thread: Re: Write a file in utf8
  • Index(es):
    • Date
    • Thread