Re: unicode to ascii (not MacRoman)
Re: unicode to ascii (not MacRoman)
- Subject: Re: unicode to ascii (not MacRoman)
- From: Neil Faiman <email@hidden>
- Date: Fri, 4 Mar 2005 07:38:54 -0500
On Mar 3, 2005, at 5:40 PM, Steven D.Majewski wrote:
I've read all of the archived messages I could find looking for a way
to coerce the unicode text I'm getting from iTunes into plain ASCII.
After none of the many methods listed worked for me, I finally figured
out from Chris Nebel's message:
http://lists.apple.com/archives/applescript-implementors/2004/Feb/
msg00039.html
that when folks in those threads were talking about ASCII plain text,
what
they *really* meant was MacRoman (or some other extended encoding)
8-bit chars.
IS there any way within applescript (other than calling out to a
python or perl
script with 'do shell script' ) to coerce a unicode string into ASCII ?
Once again ... in AppleScript, the best way to solve a problem is often
to let someone else do it for you.
Here are two possibilities:
set myString to "Émile Zôlà"
tell application "BBEdit"
make new text window with properties {contents:myString}
set myConvertedString to (convert to ASCII text 1 of text window 1)
close text window 1 saving no
end tell
Or
set myString to "Émile Zôlà"
tell application "Tex-Edit Plus"
make new window
tell window 1
set its contents to myString
strip removing diacriticals
set myConvertedString to its contents
end tell
end tell
In either case, you get "Emile Zola" in myConvertedString. (I don't
know whether the free TextWrangler would let you do the same as BBEdit,
but it's worth a try.) You also get lots of options like replacing
curly quotes with straight quotes, changing dashes to hyphens, etc.
I'm sure there are other scriptable applications that could do the same
trick. (Text Soap, maybe?)
Regards,
Neil Faiman
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden