• 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: Converting UTF-16 files to UTF-8 or MacRoman (ascii)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Converting UTF-16 files to UTF-8 or MacRoman (ascii)


  • Subject: Re: Converting UTF-16 files to UTF-8 or MacRoman (ascii)
  • From: Emmanuel <email@hidden>
  • Date: Sat, 28 Jul 2007 14:32:57 +0200

At 9:19 PM -0400 7/27/07, Mr. Dan Pouliot wrote:
I need to automate the conversion of a UTF-16 file to either UTF-8 or MacRoman. I know this can be done w/BBEdit or maybe even TextWrangler, but I was hoping for a pure AppleScript solution. I've been banging my head against a wall. I've been reading the contents of the UTF-16 file, coercing it to a string, then writing it to a new file as a string. I've even tried the "extract string" command. In very case, the new file that's made starts out MacRoman, but as soon as I dump the text into it, it becomes UTF-16. I notice that when I display dialog on the first few characters of my data I can see the BOM is there. Trying to strip out the first 2 characters makes the file go wacky from a web browser perspective. Any help would be greatly appreciated!

1/ read the file into a variable:

set s to read file "blah" as Unicode text

2/ write the variable into UTF-8:

write s to file "blah" as «class utf8»

or MacRoman:

write s to file "blah" as string

Emmanuel
_______________________________________________
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: 
 >Converting UTF-16 files to UTF-8 or MacRoman (ascii) (From: "Mr. Dan Pouliot" <email@hidden>)

  • Prev by Date: Re: Converting UTF-16 files to UTF-8 or MacRoman (ascii)
  • Next by Date: Re: AppleScript-Users Digest, Vol 4, Issue 352
  • Previous by thread: Re: Converting UTF-16 files to UTF-8 or MacRoman (ascii)
  • Next by thread: Re: AppleScript-Users Digest, Vol 4, Issue 352
  • Index(es):
    • Date
    • Thread