Bash: Convert non-ASCII characters to ASCII

watain picture watain · Dec 29, 2009 · Viewed 41.4k times · Source

How can I convert a string like Žvaigždės aukštybėj užges or äüöÖÜÄ to Zvaigzdes aukstybej uzges or auoOUA, respectively, using Bash?

Basically I just want to convert all characters which aren't in the Latin alphabet.

Thanks

Answer

Michael Krelin - hacker picture Michael Krelin - hacker · Dec 29, 2009

Depending on your machine you can try piping your strings through

iconv -f utf-8 -t ascii//translit

(or whatever your encoding is, if it's not utf-8)