Re: Converting UTF-16 files to UTF-8 or MacRoman (ascii)
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