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: Richard Rönnbäck <email@hidden>
- Date: Thu, 15 Sep 2005 09:48:23 +0200
Title: RE: Converting Mac Roman and/or UTF 16 to UTF 8?
Thanks Gnarlie , it works like a charm :-)
But what's the story of piconv? Why wouldn't it be available?
--
Richard Rönnbäck
Från: Gnarlodious <email@hidden>
Datum: Wed, 14 Sep 2005 06:59:49 -0600
Till: Applescript <email@hidden>
Ämne: 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
_______________________________________________
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