bool check_chinese(string sentence)
{
BOOST_FOREACH(auto x, sentence)
{
if( (int(x) & 0x00FF) >= 0xE0 && (int(x) & 0x00FF) <= 0xEF)
return true;
}
return false;
}
原理是utf-8编码为自由长度编码,中文字符编码的第一个字节前两位为11
bool check_chinese(string sentence)
{
BOOST_FOREACH(auto x, sentence)
{
if( (int(x) & 0x00FF) >= 0xE0 && (int(x) & 0x00FF) <= 0xEF)
return true;
}
return false;
}
原理是utf-8编码为自由长度编码,中文字符编码的第一个字节前两位为11