Fonts & Character SetsConvert UTF-8 to ISO-8859-1 (Latin-1)

Information and discussion about fonts and character sets (e.g. how to use language specific characters)
Post Reply
Noceo
Posts: 5
Joined: Wed Apr 04, 2012 8:01 pm

Convert UTF-8 to ISO-8859-1 (Latin-1)

Post by Noceo »

Hey there,

Following a new installation, I accidentally managed to create a few files in UTF-8, rather than ISO-8859-1 (also known as Latin-1 I think?) which I normally use. Now I can't by any means seem to convert these files to ISO-8859-1 encoding, no matter what I do. I tried the following with no success:
  • - Changing default Editor Font Encoding in Texmaker, making a new file and copy paste the content from the UTF-8 file.
    - Using Notepad++ to change the encoding of the files
    - Using only converters
I'm starting to get really frustrated, as each time I open one of the UTF-8 files, it shows a warning, asking me if I want to decode using UTF-8 instead of the default (ISO-8859-1).

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Convert UTF-8 to ISO-8859-1 (Latin-1)

Post by Johannes_B »

When changing a file encoding, your first step should always be a backup. You can mess things up quite easily.

The encoding of the future (i.e. future standard) is utf8, thats why all modern editors have it as its standard. So, you might consider to convert your files from latin-1 to utf-8.

Nevertheless, after backing up the files, the following workflow should work.
Open your tex-file in a normal texteditor (e.g. notepad), open texmaker/texstudio, set the default encoding to the one you prefer, create a new document and copy/paste the contents out of notepad. Don't forget to save the new file.

You should also be able to recode your documents from within texstudio/texmaker, you can try it, you backed up your files.

If you prefer to work with a command line, you can have a look at iconv:

Code: Select all

$ iconv -f utf-8 -t iso-8859-1 <yourInFile> -o <yourOutFile>
Batch convert latin-1 files to utf-8 using iconv
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Noceo
Posts: 5
Joined: Wed Apr 04, 2012 8:01 pm

Re: Convert UTF-8 to ISO-8859-1 (Latin-1)

Post by Noceo »

Thank you Johannes, I will swith to UTF-8 then. Luckily the problems I had converting away from UTF-8, doesn't seem to occur when I'm converting towards it. Thanks again for the assistance.
gusmmattos
Posts: 1
Joined: Thu Oct 08, 2015 9:52 pm

Re: Convert UTF-8 to ISO-8859-1 (Latin-1)

Post by gusmmattos »

Please, you wrote:

If you prefer to work with a command line, you can have a look at iconv:

$ iconv -f utf-8 -t iso-8859-1 <yourInFile> -o <yourOutFile>

Where do I write it? What are "yourInFile" and "yourOutFile"?

Thanks
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Re: Convert UTF-8 to ISO-8859-1 (Latin-1)

Post by Stefan Kottwitz »

Hi gusmmattos,

welcome to the forum!

Such a command is written in Command Prompt. On a Mac, I use the terminal application for it. The iconv tool is included. On a Linux system, it should be the case as well.

The "infile" is the file which you would like to convert. The "outfile" is the name of the new file, which should be created which should have the new encoding. This way you keep the original file without overwriting it.

By the way, feel free to open a new topic whenever you have a LaTeX question. It's better to see than at the end of older topics. We got space for millions of topics. ;-)

Stefan
LaTeX.org admin
Post Reply