Digging into old software, or software written on different systems, often ends up resulting in a mismatch in encoding types. Given how common this can be, most flavors of Linux and macOS come with a built-in utility for converting files between various encoding types in iconv. To use it, simply provide the source format as a -f and the target format as a -t. In the below example we’ll also bring a sourcefile.txt in using the < and kick out a targetfile.txt, or the file with the source converted using a >:
iconv -f KOI8-U -t utf-16 < sourcefile.txt > destinationfile.txt
You could also pipe the output of an echo into a screen if there isn’t that much text. In the above example we’re bringing in a file using an old Russian encoding scheme and kicking it out as UTF-16; however, there are dozens of encoding standard supported. To see a list of them, use –list with the command:
iconv --list