csv特殊字符出现问题 [英] Problem with csv special characters

查看:337
本文介绍了csv特殊字符出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题:我已经读取一个csv文件,并将内容存储到一个datatable,一切正常。但是当我在datagridview中显示datatable的内容时,当我有符号€或is,and ...时,我只看到一个带有问号的钻石。如何解决这个问题?感谢

I have a problem: I have read a csv file and store the contents into a datatable, and everything is ok. But when I show the contents of the datatable in a datagridview, when I have the symbols "€" or "is, and ..." I only see a diamond with a question mark inside. How can I fix this? thanks

推荐答案

您需要使用正确的编码加载文件。

You need to load the file with correct encoding.

将编码传递给 StreamReader 的构造函数:

pass the encoding to the constructor of StreamReader :

StreamReader sw = new StreamReader (fileName, Encoding.ASCII);



注意



编码您的文件有我只是猜测是ASCII

这篇关于csv特殊字符出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆