Re: Converting Mac Roman and/or UTF 16 to UTF 8?
Re: Converting Mac Roman and/or UTF 16 to UTF 8?
- Subject: Re: Converting Mac Roman and/or UTF 16 to UTF 8?
- From: Gnarlodious <email@hidden>
- Date: Wed, 14 Sep 2005 06:59:49 -0600
Title: Re: Converting Mac Roman and/or UTF 16 to UTF 8?
Entity Richard Rönnbäck spoke thus:
> Is there a way to convert a text file with one encoding, to another
> encoding, using standard AppleScript or shell commands only, and without
> relying on external applications?
Here’s a snippet from one of my scripts that uses iconv or piconv in the process of making a webpage from a browser hotlist:
on tryUnicode(codeConversion) -- wrapBody must be called first!
if codeConversion then
try -- convert from Hotlist's MacRoman encoding to UTF-8
try -- iconv first
do shell script "iconv -f macintosh -t utf-8 /private/tmp/flip>/private/tmp/flop"
on error -- maybe piconv is available?
do shell script "piconv -f MacRoman -t utf-8 /private/tmp/flip>/private/tmp/flop"
end try
on error -- keep what we have
-- special characters might look bad on Windoze machines, but who cares?
return
end try
-- at this point the conversion was successful
do shell script "sed -e '4s|\\([^>]*\\)charset=macintosh\\([^>]*\\)|\\1charset=utf-8\\2|' /private/tmp/flop>/private/tmp/flip"
Etc
You can see the entire script here:
http://Gnarlodious.com/Apple/AppleScript/Scripts/iCab-iPage.html
-- Gnarlie
_______________________________________________
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