[Tex/LaTex] How to convert UTF-8 to latin-1 on the fly


I have my whole latex document which is encoded in latin-1. Also, the documentclass provided by my institution is designed to use latin-1. I write in french.

I wish to use .bib files created by Mendeley which are encoded in UTF-8. When I try to compile, latex gives me an error :

inputenc: Keyboard character used is undefined(inputenc) in inputencoding `latin1'.

Is there a way to convert the encoding on the fly with a simple command? Here is my setup :

Windows 7

MiKTeX 2.9

TexStudio 2.3

Mendeley to export my .bib

It's just a matter of changing the encoding since if I simply copy the content of the .bib file in a new file (with the right encoding setup in TexStudio), everything works fine. I don't want to do that since it breaks my workflow. I'm thinking of something like a command to add before the execution of pdflatex.

Best Answer

You don't need to reencode your files. LaTeX is quite able to input an utf8 encoded file in ansinew/latin1 encoded main file:

\inputencoding{ansinew} %back to ansinew

But if you are using biblatex/biber you probably don't have to worry at all: If your bib-file contains only chars which are also covered by ansinew, then biber will convert the utf8 to ansinew when generating the bbl. This here works without problem for me: (the bib contains german umlauts.)


Btw: On windows you should normaly use ansinew instead of latin1 so that e.g. also the € is processed correctly.