• 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 Mac Roman and/or UTF 16 to UTF 8?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • RE: Converting Mac Roman and/or UTF 16 to UTF 8?
      • From: Richard Rönnbäck <email@hidden>
References: 
 >Converting Mac Roman and/or UTF 16 to UTF 8? (From: Richard Rönnbäck <email@hidden>)

  • Prev by Date: Q: Add one pixel on right / GraphicConverter
  • Next by Date: Re: Q: Add one pixel on right / GraphicConverter
  • Previous by thread: Re: Converting Mac Roman and/or UTF 16 to UTF 8?
  • Next by thread: RE: Converting Mac Roman and/or UTF 16 to UTF 8?
  • Index(es):
    • Date
    • Thread