您的位置:首页 > 其它

Determine whether the text is in Chinese or English

2017-09-22 15:05 435 查看
public  bool IsChineseCharacter (string str)
{
Regex regChina = new Regex ("^[^\x00-\xFF]");
Regex regEnglish = new Regex ("^[a-zA-Z]");

if (regEnglish.IsMatch (str)) {
return false;
}
else if (regChina.IsMatch (str)) {
return true;
}
else
{
return false;
}

//byte [] byte_len = System.Text.Encoding.Default.GetBytes (ch);
//if (byte_len.Length == 2) { return true; }

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐