I have a tex file with:


The file calls a macro that saves the content between and \begin{something} and \end{something} to a file. But the encoding of the file is not utf8. Is there a way to set encoding of the output file (I can rewrite the macro if necessary).

The macro is:

    \begingroup \catcode`\^^M=12 %



I have simplified the macro:



This makes the code much easier, but the encoding is still not right. It seems that the internal representation is used.

  • tex.stackexchange.com/q/58178/3734 – F'x Nov 16 '13 at 16:44
  • Is there something like \outputencoding{latin9 or whatever} from outputenc package while writing to external files ? – texenthusiast Nov 16 '13 at 16:47
  • How are \something and \@xsomething defined? – egreg Nov 16 '13 at 17:13
  • all standard latex file writing should write just using LICR ie ascii TeX notation so be compatible with utf-8, – David Carlisle Nov 16 '13 at 17:44

With \usepackage[utf8]{inputenc} characters with the high bit set are made active and verbatim environments don't change this. You can do it yourself:

I called this file hernan.tex, so the output file will be hernan.out:




Questo è il mio testo.



The contents of hernan.out is


If I look at it with LESSCHARSET=ascii less hernan.out I get this


which shows correct UTF-8.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.