在C#怎么样判断字符是否为中文
发布:liao | 发布时间: 2008年1月30日我们研究下在C#中怎么样判断字符是否为中文呢?今天就来研究下这个问题.或者下面这个就是你要的签,赶快试下
unicode 字符串中,中文的范围是在4E00..9FFF:CJK Unified Ideographs。
通过对字符的unicode编码进行判断来确定字符是否为中文。
protected bool IsChineseLetter(string input,int index)
......{
int code = 0;
int chfrom = Convert.ToInt32("4e00", 16); //范围(0x4e00~0x9fff)转换成int(chfrom~chend)
int chend = Convert.ToInt32("9fff", 16);
if (input != "")
......{
code = Char.ConvertToUtf32(input, index); //获得字符串input中指定索引index处字符unicode编码
if (code >= chfrom && code <= chend) 
......{
return true; //当code在中文范围内返回true
}
else
......{
return false ; //当code不在中文范围内返回false
}
}
return false;
}
- 相关文章:
.net分布式事务例子 (2008-1-30 23:30:33)
ASP.NET生成静态方法(C#) (2008-1-24 18:3:36)
asp.net中当服务器出错时显示指定的错误页面 (2008-1-20 22:30:36)
开发Excell控件 (2008-1-17 23:35:30)
c# .net自定义控件开发实例 (2008-1-17 23:26:43)
ASP.NET开发购物车方法 (2008-1-13 23:50:39)
ASP.NET中TreeView控件使用方法 (2008-1-13 23:47:50)
什么asp.net技术 (2008-1-10 8:24:26)
如何为datagrid的分页添加首页、尾页及状态功能 (2008-1-8 21:20:25)
学asp.net第十天 (2007-12-26 23:24:29)
发表评论
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。





