过滤非法字符 三
来源:互联网 发布:社区红色网络家园 编辑:程序博客网 时间:2024/05/01 07:13
实现文件:
#include "stdafx.h"
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include "WordLib.h"
#include "_string.h"
namespace WordLib{
typedef std::basic_string<char, ChatTraintsEx> __String;
typedef std::vector<__String> __WordList;
static const char* __strWordLib[] = {
"***",
"***",
"***",
"**** ",
"**** you",
"script"
};
static __WordList __wordList;
static __String __nullStr = " ";
void __InitWordList()
{
if(__wordList.size() != 0)
return ;
for(size_t i = 0; i < sizeof(__strWordLib) / sizeof(const char*); ++i)
__wordList.push_back(__strWordLib[i]);
std::sort(__wordList.begin(), __wordList.end());
}
bool _FLYINGMAGIC_2_CUT_WORD IsValid(const char* str)
{
__InitWordList();
if(str != NULL)
{
__String strSrc(str);
__WordList::iterator itEnd = __wordList.end();
for(__WordList::iterator it = __wordList.begin(); it != itEnd; ++it)
{
if(strSrc.find(*it) != -1)
return false;
}
}
return true;
}
bool _FLYINGMAGIC_2_CUT_WORD Filtrate(char* dst, size_t len, const char* src)
{
__InitWordList();
bool bRet = false;
if(src != NULL && dst != NULL && strlen(src) <= len)
{
__String strSrc(src);
__WordList::iterator itEnd = __wordList.end();
for(__WordList::iterator it = __wordList.begin(); it != itEnd; ++it)
{
__String::size_type begin = strSrc.find(*it);
if(begin != -1)
{
for(__String::size_type t = 0; t < it->size(); ++t)
strSrc[begin + t] = ' ';
// strSrc.assign(__nullStr, begin, it->size());
bRet = true;
}
}
strcpy(dst, strSrc.c_str());
}
return bRet;
}
}
- 过滤非法字符 三
- 过滤非法字符 一
- 过滤非法字符 二
- asp过滤非法字符
- Filter过滤非法字符
- 过滤非法字符
- 过滤非法字符
- 过滤非法字符问题
- 过滤非法字符
- java过滤非法字符
- 过滤xml非法字符
- 过滤非法字符
- servlet过滤非法字符
- dom4j 非法字符过滤
- 过滤非法字符函数
- 过滤文件名非法字符
- .net过滤非法字符
- 过滤xml非法字符
- ADO.NET2.0的十大新特性
- vxWorks下编写字符设备驱动程序的方法。
- 男人是动物,女人是植物
- 过滤非法字符 一
- 过滤非法字符 二
- 过滤非法字符 三
- Struts中文乱码问题解决
- 接口的应用
- C++ 排序算法
- test
- 在校友录上免费发多彩留言!
- 没有备份、只有归档日志,如何恢复数据文件?
- 善用色彩设计网页
- 创建您自己的集合类(CollectinBase的使用)