Linux: Convert File Encoding with iconv

By Xah Lee. Date:

The GNU command line tool iconv does character encoding conversion.

# convert a file from utf-16 to utf-8
iconv -f utf-16 -t utf-8 file1.txt > file2.txt

iconv -l → show a list of encodings.

See also: Emacs File Encoding FAQ

File Encoding

  1. Unicode Basics: Character Set, Encoding, UTF-8, Codepoint
  2. HTML: Character Sets and Encoding
  3. Unicode in Ruby, Perl, Python, JavaScript, Java, Emacs Lisp, Mathematica
  4. Python: Unicode Tutorial 🐍
  5. Python: Convert File Encoding
  6. Python: Convert File Encoding for All Files in a Dir
  7. Perl: Unicode Tutorial 🐪
  8. Perl: Convert File Encoding
  9. Ruby: Unicode Tutorial 💎
  10. Java: Convert File Encoding
  11. Linux: Convert File Encoding with iconv

If you have a question, put $5 at patreon and message me.