Conversion from EBCDIC to UTF8 in Linux

luca76 picture luca76 · Apr 8, 2016 · Viewed 12.7k times · Source

I have imported with Perl a table from our database AS/400 DB2.

The problem is that the string are encoded in EBCDIC Latin-1 (italian language).

How can I convert the resulting file to plain utf-8 in Linux bash?

Answer

DevSolar picture DevSolar · Apr 8, 2016

Start with

iconv -f EBCDIC-IT -t utf-8 <filename>

then check the output, and if it isn't exactly correct, check man iconv and the available encodings listed by iconv -l.

(Note that "EBCDIC Latin-1" is somewhat strange. "Latin-1" indicates ISO-8859-1, while "EBCDIC" is something else entirely. Try file <filename> to get an educated guess by the computer as to what encoding you are actually looking at.)