tags:

views:

100

answers:

1

Hi, i have the next code written in C#....it create a tex file using utf-8.....the problem is that appears that is not a real valid utf-8 file because, when i use pdflatex it doesn't recognize the characters with accents. Somebody knows a way to write a real UTF-8 file? When i use TexmakerX to create a utf8 file with the same latex code, pdflatex doesn't complaints, so the problem must be in the generation.

                    StreamWriter writer = new StreamWriter("hello.tex", false, Encoding.UTF8);

        writer.Write(@"\documentclass{article}" + "\n" +
                     @"\usepackage[utf8]{inputenc}" + "\n" +
                    @"\usepackage[spanish]{babel}" + "\n" +
                        @"\usepackage{listings}" + "\n" +
                        @"\usepackage{fancyvrb}" + "\n" +
                        @"\begin{document}" + "\n" +
                        @"\title{asd}" + "\n" +
                        @"\maketitle" + "\n" +
                        @"\section{canción}" + "\n" +

                        @"canción" + "\n" +

                        @"\end{document}");
        writer.Close();
+1  A: 

This might be a problem with a missing Unicode byte-order mark (BOM). You might check this by using a custom UTF8Encoding:

using (StreamWriter writer = 
    new StreamWriter("hello.tex", false, new UTF8Encoding(true, true)))
{

}
0xA3
thanks that works flawless.
voodoomsr