欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

c#通過unicode編碼判斷字符是否為中文示例分享

 更新時間:2014年01月06日 14:20:07   作者:  
本文介紹了c#通過unicode編碼判斷字符是否為中文的示例,在unicode字符串中,中文的范圍是在4E00..9FFF:CJK Unified Ideographs。通過對字符的unicode編碼進行判斷來確定字符是否為中文

復(fù)制代碼 代碼如下:

protected bool IsChineseLetter(string input,int index)
{
int code = 0;
int chfrom = Convert.ToInt32("4e00", 16); //范圍(0x4e00~0x9fff)轉(zhuǎn)換成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在中文范圍內(nèi)返回true

}
else
{
return false ; //當code不在中文范圍內(nèi)返回false
}
}
return false;
}

相關(guān)文章

最新評論