How to read file with iso-8859-1 latin1 encoding?

What package should I install to be able to read files with iso-8859-1 latin1 encoding?

Currently, I only see strange characters instead of text.

% locale
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

1 Answer

The latin1 encoding is "mostly" compatible with UTF-8, since both encodings are supersets of ASCII. This means that you should see normal letters (a-z) but not diacritics (é, è, and so on). Let's try to understand what is the actual encoding of your file.

First, the file command can sometimes detect the encoding. Simply use:

$ file weird_file

You could get weird_file: ISO-8859 text for latin1, weird_file: UTF-8 Unicode text for UTF-8, or something else. Now, if you determined that it is latin1, the best way to display it is actually to open an editor, like gedit, and choose the correct encoding when opening the file. If you want to convert the file to UTF-8, you can then 'Save as' and ask for UTF-8.

If you still don't know the encoding, try to open the document with Libre Office, it's usually good at detection. It's also possible that your file is corrupted (eg. UTF-8 text interpreted as latin1 and saved as UTF-8), or, more likely, that it never contained text. Feel free to upload it so that we can inspect it.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like