上传者: 38673548
|
上传时间: 2022-03-02 15:04:08
|
文件大小: 93KB
|
文件类型: -
前言
最近在处理游戏敏感词之类的东西,为了加强屏蔽处理,所以需要过滤掉字符串中的除汉字之外的是其他东西如数字,符号,英文字母等。
首先我查阅资料并写了个函数:
示例:返回输入字符串中汉字的个数:
std::string StrWithOutSymbol(const std::string &source)
{
string sourceWithOutSymbol;
int i = 0;
while (source[i] != 0)
{
if (source[i] & 0x80 )
{
sourceWithOutSymbol += source[i];
source