【问题标题】:Convert file.Inputstream to UTF-8 c#将file.Inputstream转换为UTF-8 c#
【发布时间】:2016-03-23 12:20:31
【问题描述】:

我正在处理 csv 导入,并且正在接收一个西欧编码的文件。像 ü 这样的某些字符显示不正确。 但是,当我将文件另存为 UTF-8 编码时,它工作正常。 有什么方法可以将我收到的上传文件编码为 UTF-8 ?使用 CSVHelper 解析 CSV

  ICsvParser csvParser = new CsvParser(new StreamReader(stream));

  CsvReader csvReader = new CsvReader(csvParser);

  while (csvReader.Read())
        {
          .. do something
        }

【问题讨论】:

    标签: c# encoding utf-8


    【解决方案1】:

    如果文件以西方编码方式编码,请尝试使用new StreamReader(stream, Encoding.GetEncoding("windows-1252"))

    【讨论】:

      猜你喜欢
      • 2015-01-14
      • 2015-09-21
      • 1970-01-01
      • 2011-04-18
      • 2012-01-08
      • 2023-03-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多