< BACK

Bash tips, tricks and code snippets

Convert file from iso-8859-1 to utf8

Using this reference, first check that the input file is actually the encoding type which needs to be converted from:

file -i ama.m3u
ama.m3u: text/plain; charset=iso-8859-1

Doing a cat of the file when the terminal is set to display utf8 looks like this:

#EXTCPlayListM3U::M3U
#EXTINF:0,02. Am�lia Rodrigues - Maldi��o
nfs://192.168.178.237/mnt/dropbox/Dropbox/audio/Music/_latin/Am�lia_Rodrigues/O melhor de Amalia Vol. II - Tudo isto e fado/1-02_Maldi��o.mp3

So converting with iconv

iconv -f ISO-8859-1 -t UTF-8//TRANSLIT ama.m3u -o ama_utf8.m3u 

results in the file appearing like this:

#EXTCPlayListM3U::M3U
#EXTINF:0,02. Amália Rodrigues - Maldição
/mnt/Music/_latin/Amália_Rodrigues/O melhor de Amalia Vol. II - Tudo isto e fado/1-02_Maldição.mp3