资源简介
基于C#语言,可自行改为c即可用于c++
一个判断字符串编码类型的类,支持多种常见编码

代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Text;
namespace MyEncoding
{
#region Class IdentifyEncoding.....
///
/// 检测字符编码的类
///
///
///
///
///
/// /// IdentifyEncoding 用来检测 字节数组的编码.
/// Create By lion
/// 2005-02-21 22:00
/// Support .Net framework v1.1.4322
/// WebSite:www.lionsky.net(lion-a AT sohu.com)
/// ]]>
///
public class IdentifyEncoding
{
#region Fields.....
// Frequency tables to hold the GB Big5 and EUC-TW character
// frequencies
internal static int[][] GBFreq = new int[94][];
internal static int[][] GBKFreq = new int[126][];
internal static int[][] Big5Freq = new int[94][];
internal static int[][] EUC_TWFreq = new int[94][];
internal static string[] nicename =
new string[] { “GB2312“ “GBK“ “HZ“ “Big5“ “CNS 11643“ “ISO 2022CN“ “UTF-8“ “Unicode“ “ASCII“ “OTHER“ };
#endregion
#region Methods.....
///
/// 初始化 的实例
///
public IdentifyEncoding()
{
Initialize_Frequencies();
}
#region GetEncodingName.....
///
/// 从指定的 中判断编码类型
///
/// 要判断的
/// 返回编码类型(“GB2312“ “GBK“ “HZ“ “Big5“ “CNS 11643“ “ISO 2022CN“ “UTF-8“ “Unicode“ “ASCII“ “OTHER“)
///
/// 以下示例演示了如何调用 方法:
///
/// IdentifyEncoding ide = new IdentifyEncoding();
/// Response.Write(ide.GetEncodingName(new Uri(“http://china5.nikkeibp.co.jp/china/news/com/200307/pr_com200307170131.html“)));
///
///
public virtual string GetEncodingName(System.Uri testurl)
{
sbyte[] rawtext = new sbyte[1024];
int bytesread = 0 byteoffset = 0;
System.IO.Stream chinesestream;
try
{
chinesestream = System.Net.WebRequest.Create(testurl.AbsoluteUri).GetResponse().GetResponseStream();
while ((bytesread = ReadInput(chinesestream ref rawtext byteoffset rawtext.Length - byteoffset)) > 0)
{
byteoffset += bytesread;
}
chinesestream.Close();
}
catch
{
throw;
}
return GetEncodingName(rawtext);
}
///
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 100004 2010-11-03 13:15 IdentifyEncoding.cs
----------- --------- ---------- ----- ----
100004 1
相关资源
- 百度C++编码规范
- GBT 28169-2011 嵌入式软件 C语言编码规范
- 缩短循环码(2616)编译码程序-C语言
- pcm语音编码
- UNIX/LINUX下C语言中文短信UCS2编码和解
- 信息论课程设计——LZW编码
- c语言实现bch编码
- 个人总结的一些C/C++编码规范
- 谷歌C++编码规范 Google C++ 风格指南
- C语言实现LZW编码
- C++实现的改进遗传算法
- MFC莫尔斯电码的编码发声
- Google-C++编码规范中文版最新整理PDF版
- spiht算法小波图像编码算法
- 图的抽象数据类型实现
- GBT28169-2011嵌入式软件C语言编码规范
- 嵌入式软件C语言编码规范(高安全性
- C语言变量类型详解史上最全
- 密码编码学:加密方法的C与C++实现
- MMX-密码编码学:加密方法的C与C++实现
- MFC 一维码生成+打印 支持多种编码1
- Huffman和算术编码的C++实现
- 基于JPEG2000的图像编码与解码c++版
- 简单实现的自适应算术编码
- 谷歌C++编码规范-中文 2018-03-30 最新版
- jbig二值图像压缩算法编码实现
- VC++串口通信编码
- 哈夫曼编码译码器数据结构
- 编码:隐匿在计算机软硬件背后的语
- mfc打开各种类型图片范例
评论
共有 条评论