utf8 codification problem C#, writing a tex file, and compiling with pdflatex
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();
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)))
{
}
精彩评论