//判断是否为常规gb2312编码区间
static bool isValidStr(std::string data)
{
if(data.empty())
{
return false;
}
std::string invalidStr = ", . ? / *:'\"<>|\\;";
if(data.find_first_of(invalidStr) != std::string::npos)
{
return false;
}
UINT sz = data.length();
UINT index = 0;
while(true)
{
if(index == sz)
{
break;
}
BYTE val = data[index];
if(val == 0)
{
return false;
}
if(val < 0x7f)
{
//is ascii
++index;
continue;
}
else if(val < 0xa1)
{
return false;
}
if(index + 1 == sz)
{
return false;
}
//空白段
if(val > 0xa9 && val < 0xb0 || val > 0xf7)
{
return false;
}
BYTE nextVal = data[index + 1];
if(nextVal < 0xa0 || nextVal > 0xff)
{
return false;
}
index += 2;
}
return true;
}