读取UTF8文件并转换为普通文本. [英] Read UTF8 file and convert to normal text.

查看:79
本文介绍了读取UTF8文件并转换为普通文本.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计们,我只是想知道是否有一种方法可以读取UTF8编码的文件并将其转换为纯文本.我可以正常读取文件,但是无论如何我都无法将其转换为纯文本.任何帮助都非常感谢.

Hey guys, i''m just wondering is there a way to read in a UTF8 encoded file and convert it to plain text. I can read the file in alright but no matter what I do I can''t convert it to plain text. Any help very much apreciated thanks.

推荐答案

这里是解决方案.

Here is the solution.

FileStream stream = new FileStream( fileName, System.IO.FileMode.Open );
BinaryReader reader = new BinaryReader( stream );
string text = Encoding.UTF8.GetString( reader.ReadBytes( (int)reader.BaseStream.Length ) );


这篇关于读取UTF8文件并转换为普通文本.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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