diff --git a/CMakeLists.txt b/CMakeLists.txt index 9a6d5f9..00bb843 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/src/SegmentBase.hpp b/src/SegmentBase.hpp index 1e6168e..4fe73b2 100644 --- a/src/SegmentBase.hpp +++ b/src/SegmentBase.hpp @@ -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 } };