简体   繁体   English

使用FileHelpers解析带有法式重音的逗号分隔值文件

[英]Parsing a Comma-seperated values file with french accents in it using FileHelpers

I've been using the FileHelpers library in C# to parse a comma-seperated values file full of student names. 我一直在使用C#中的FileHelpers库来解析充满学生姓名的逗号分隔值文件。 Some of the names however contain french accents such as "é", and I've noticed that FileHelpers doesn't parse these accents properly. 但是,其中一些名称包含法语重音,例如“é”,我注意到FileHelpers不能正确解析这些重音。 An example name is "Chloé", which upon parse is turned into "Chloé". 示例名称为“Chloé”,在解析后将其转换为“Chloé”。

Is there any way I can parse the accents properly? 有什么方法可以正确解析口音吗? This is the relevant code. 这是相关的代码。

var engine = new FileHelperEngine<RawStudent>();
    try
    {
    // Make result into an array of Student
    var result = engine.ReadFile(path);

And the class that I'm writing the data to. 还有我要将数据写入的类。

public class RawStudent
{
    [FieldNotEmpty]
    public string First;
    [FieldNotEmpty]
    public string Last;
    [FieldNotEmpty]
    public int Id;
    [FieldNotEmpty]
    public int Grade;
    [FieldNotEmpty]
    public int Homeroom;
}

您需要将engine.Encoding设置为Encoding.UTF8

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM