utf8编码问题C#,编写tex文件,并用pdflatex编译
我用 C# 编写了下一个代码....它使用 utf-8 创建一个 tex 文件...问题是这似乎不是一个真正有效的 utf-8 文件,因为当我使用 pdflatex 时它不会无法识别带有重音符号的字符。有人知道如何编写真正的 UTF-8 文件吗?当我使用 TexmakerX 创建具有相同 Latex 代码的 utf8 文件时,pdflatex 不会抱怨,所以问题一定出在生成中。
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();
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();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可能是由于缺少 Unicode 字节顺序标记 (BOM) 造成的问题。您可以使用自定义
UTF8Encoding
:This might be a problem with a missing Unicode byte-order mark (BOM). You might check this by using a custom
UTF8Encoding
: