Filehelpers库无法读取™字符

问题描述 投票:0回答:1

我正在使用Filehelpers.Net库,我有一个我想读的CSV文件。其中一列具有character™。

我收到了一个错误

行:1054列:357。找不到值类型字段的值:'Comment'类:'ClientOrders'。您必须使用[FieldNullValue]属性,因为这是一个值类型,不能为null或使用Nullable Type而不是当前类型。

我在Notepad ++中打开了文件,我可以看到这个无效字符位于错误给出的位置。

如何强制Filehelpers读取此字符?

更新:这是我的代码

// Create a UTF-8 encoding.
UTF8Encoding utf8 = new UTF8Encoding();
var engine = new FileHelperEngine<ClientOrders>(utf8);

ClientOrders[] fileResult = engine.ReadFile(csvFile.FullName);
c# .net filehelpers
1个回答
1
投票

你有没有设置正确的编码?我想你想设置编码:

    // Create a UTF-8 encoding.
    UTF8Encoding utf8 = new UTF8Encoding();

    var helper = new FileHelperEngine(recordType, utf8);
© www.soinside.com 2019 - 2024. All rights reserved.