c++删除字符串特殊符号

std::string RemoveSpcSymbol(std::string strSource)//删除符号
{
	char *str = strSource.c_str();
	char buf[MAX_PATH] = { 0 };
	int j = 0;

	for (int i = 0; i < strlen(str); i++)
	{
		if (str[i] > 0 && str[i] < 0x7F)
		{
			if (str[i] >= '0' && str[i] <= '9')
			{
				buf[j] = str[i]; j++;
			}

			if (str[i] >= 'A' && str[i] <= 'Z')
			{
				buf[j] = str[i]; j++;
			}

			if (str[i] >= 'a' && str[i] <= 'z')
			{
				buf[j] = str[i]; j++;
			}
			continue;
		}

		if ((unsigned char)str[i] >= 0xB0 && (unsigned char)str[i] <= 0xF7)
		{
			if ((unsigned char)str[i + 1] >= 0xA0 && (unsigned char)str[i + 1] <= 0xFF)
			{
				buf[j] = str[i]; j++; i++;
				buf[j] = str[i]; j++;
				continue;
			}
		}
		i++;
	}
	return buf;
}

阅读更多

没有更多推荐了,返回首页