Apple - Is there a Mac OS X Command Line application that can convert text encodings from one type to another? (Specifically to convert Mac OS Roman to utf8)
iconv
is definitively the tool of choice here:
iconv -f MACROMAN -t UTF-8 your-roman-encoded-file.txt > utf-8-encoded-file.txt
Run iconv --list
to see a list of all supported encodings.
Another way to convert non-ASCII characters to ASCII variants is to use iconv -t ASCII//TRANSLIT
:
$ echo ‘’“”–—…äé | iconv -t ASCII//TRANSLIT
''""--..."a'e
ASCII//IGNORE
would remove non-ASCII characters, but you can also do that with for example tr -dc '\0-\177'
.