File Encoding Conversion
Posted by Paolo Wed, 27 Feb 2008 18:47:00 GMT
This morning I struggled a bit to find a decent encoding converter for osx… from time to time I get stuck on encoding issues so I wanted to have something ‘friendly’ to handle this kind of problems…
I found Cyclone based on Apple Text Encoding Converter (look for TEC) but it kept failing in some strange ways (It gave me weird messages about converters creation). After googling for a while I gave up. It seems there are no good-free-GUI alternatives on the net…
Sometimes the solution is closer than you think and the good old iconv rescued me in a snap:
[paolo@fingus]$ iconv -f UTF-16 -t UTF-8 utf16_file.txt > utf8_file.txt
you can list the available encodings with:
[paolo@fingus]$ iconv -l
The cool part is you can use it in conjunction with TextMate’s Filter Through Command feature thus enabling in-editor lightning-fast conversions.
The only missing part was discovering the original file’s encoding, in order to pass iconv the correct -f option. The not-so-reliable way I used was to open the file with Firefox and inspect the encoding using the View -> Character Encoding menu item.
That’s it, problem solved. If you know better ways to do this… let me know!







