mirror of
https://github.com/yanyiwu/cppjieba.git
synced 2025-07-18 00:00:12 +08:00
add NO_FILTER macro
This commit is contained in:
parent
45a5df5856
commit
18de12a21c
@ -4,6 +4,7 @@ ADD_DEFINITIONS(-std=c++0x -O3)
|
||||
IF (DEFINED ENC)
|
||||
ADD_DEFINITIONS(-DCPPJIEBA_${ENC})
|
||||
ENDIF()
|
||||
#ADD_DEFINITIONS(-DNO_FILTER)
|
||||
ADD_SUBDIRECTORY(src)
|
||||
ADD_SUBDIRECTORY(dicts)
|
||||
ADD_SUBDIRECTORY(scripts)
|
||||
|
@ -31,13 +31,22 @@ namespace CppJieba
|
||||
LogError("not inited.");
|
||||
return false;
|
||||
}
|
||||
Unicode unico;
|
||||
#ifdef NO_FILTER
|
||||
unico.clear();
|
||||
if(!TransCode::decode(str, unico))
|
||||
{
|
||||
LogFatal("str[%s] decode failed.", str.c_str());
|
||||
return false;
|
||||
}
|
||||
return cut(unico.begin(), unico.end(), res);
|
||||
#else
|
||||
const char * const cstr = str.c_str();
|
||||
uint size = str.size();
|
||||
uint offset = 0;
|
||||
string subs;
|
||||
int ret;
|
||||
uint len;
|
||||
Unicode unico;
|
||||
while(offset < size)
|
||||
{
|
||||
const char * const nstr = cstr + offset;
|
||||
@ -65,6 +74,7 @@ namespace CppJieba
|
||||
offset += len;
|
||||
}
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user