当前位置: 首页 > news >正文

网站建设为了什么/优化大师班级

网站建设为了什么,优化大师班级,石景山网站建设,济南槐荫区做网站的本文实例讲述了C#读取中文文件出现乱码的解决方法。分享给大家供大家参考。具体分析如下:先来看这段代码:FileStream aFile new FileStream(SingleFile,FileMode.Open);StreamReader sr new StreamReader(aFile,Encoding.GetEncoding("gb2312&quo…

本文实例讲述了C#读取中文文件出现乱码的解决方法。分享给大家供大家参考。具体分析如下:

先来看这段代码:

FileStream aFile = new FileStream(SingleFile,FileMode.Open);

StreamReader sr = new StreamReader(aFile,Encoding.GetEncoding("gb2312"),true);

string FileContent = sr.ReadToEnd();

aFile.Close();

ProcessData Pd = new ProcessData();

Pd.ProceData(FileContent);

StreamReader 使用3个参数 最后一个自动检测utf-8,中文大部分是gb2312,如果不是utf-8,就用gb2312

系统自带utf 检测 ,见如下:

private void DetectEncoding()

{

if (this.byteLen >= 2)

{

this._detectEncoding = false;

bool flag = false;

if ((this.byteBuffer[0] == 0xfe) && (this.byteBuffer[1] == 0xff))

{

this.encoding = new UnicodeEncoding(true, true);

this.CompressBuffer(2);

flag = true;

}

else if ((this.byteBuffer[0] == 0xff) && (this.byteBuffer[1] == 0xfe))

{

if (((this.byteLen < 4) || (this.byteBuffer[2] != 0)) || (this.byteBuffer[3] != 0))

{

this.encoding = new UnicodeEncoding(false, true);

this.CompressBuffer(2);

flag = true;

}

else

{

this.encoding = new UTF32Encoding(false, true);

this.CompressBuffer(4);

flag = true;

}

}

else if (((this.byteLen >= 3) && (this.byteBuffer[0] == 0xef)) && ((this.byteBuffer[1] == 0xbb) && (this.byteBuffer[2] == 0xbf)))

{

this.encoding = Encoding.UTF8;

this.CompressBuffer(3);

flag = true;

}

else if ((((this.byteLen >= 4) && (this.byteBuffer[0] == 0)) && ((this.byteBuffer[1] == 0) && (this.byteBuffer[2] == 0xfe))) && (this.byteBuffer[3] == 0xff))

{

this.encoding = new UTF32Encoding(true, true);

this.CompressBuffer(4);

flag = true;

}

else if (this.byteLen == 2)

{

this._detectEncoding = true;

}

if (flag)

{

this.decoder = this.encoding.GetDecoder();

this._maxCharsPerBuffer = this.encoding.GetMaxCharCount(this.byteBuffer.Length);

this.charBuffer = new char[this._maxCharsPerBuffer];

}

}

}

希望本文所述对大家的C#程序设计有所帮助。

http://www.lbrq.cn/news/1240165.html

相关文章:

  • 做窗帘网站图片大全/哪个网站做推广效果好
  • 网站内页如何做排名/优化大师百科
  • dw做旅游网站教程/北京网站优化推广方案
  • 网站参考模板/seo项目完整流程
  • 移动网站开发的视频下载/广告联盟app下载
  • 网站建设启动资金预算/seo网站搭建是什么
  • 治多县网站建设公司/新营销模式有哪些
  • 绵阳网站建设开发/seo快速排名软件品牌
  • 乐云网站建设/cms建站
  • 响应式网站建设外文文献/bt种子磁力搜索引擎
  • 漳州做网站含博大网/实时热榜
  • 做ppt介绍网站/网络推广费用
  • 建站网站图片不显示/9 1短视频安装
  • 京东网站难做吗/关键词广告
  • Wordpress 手机网站/网络推广员工作好做吗
  • 一键优化下载安装/江苏seo外包
  • 中教在线3d建模培训/seo推广排名
  • 乌兰县网站建设公司/百度sem优化师
  • 这是我做的网站/友情链接交换软件
  • 怎样做自己的微商网站/百度网站推广价格
  • 自己公司内网网站和外网怎么做同步/免费的发帖收录网站
  • 开发平台网站多少钱/海阳seo排名优化培训
  • 武穴市住房和城乡建设局网站/友情链接教程
  • 有赞微商城官网登录/seo网站排名的软件
  • 如何做网站预览/项目网
  • 商务网站设计与制作/百度咨询
  • 网站在vps能访问 在本地访问不了/学校seo推广培训班
  • 做门户型网站/网站视频
  • 七牛云建网站/下载百度app最新版到桌面
  • 牡丹江市营商环境建设监督局网站/廊坊关键词排名优化
  • 专网内网IP攻击应急与防御方案
  • 快速了解决策树
  • 分布式事务----spring操作多个数据库,事务以及事务回滚还有用吗
  • Highly Compressed Tokenizer Can Generate Without Training
  • Day25-对称二叉树-
  • Allegro降版本工具