gix bug by updating cppcommon/str_functs.cpp

This commit is contained in:
gwdwyy 2013-07-19 15:36:42 +08:00
parent 92e5234b4a
commit 1e246d6bb8
2 changed files with 8 additions and 4 deletions

View File

@ -149,7 +149,7 @@ namespace CppJieba
bool KeyWordExt::extract(const string& utf8Str, vector<string>& keywords, uint topN)
{
LogInfo(string_format("title:[%s]",utf8Str.c_str()));
LogDebug(string_format("title:[%s]",utf8Str.c_str()));
bool retFlag;
vector<string> words;
@ -177,7 +177,7 @@ namespace CppJieba
}
//LogDebug("_extractTopN finished.");
LogInfo(string_format("ext res:[%s]", joinStr(keywords, ",").c_str()));
LogDebug(string_format("ext res:[%s]", joinStr(keywords, ",").c_str()));
return true;
}

View File

@ -331,14 +331,18 @@ namespace CPPCOMMON
string gbkToUtf8(const string& gbk)
{
//cout<<__FILE__<<__LINE__<<gbk<<endl;
string res;
if(gbk.empty())
{
return "";
}
string res("");
size_t maxLen = gbk.size()*4;
char * pUtf = new char[maxLen];
int ret = code_convert("gbk", "utf-8", (char *)gbk.c_str(), gbk.size(), pUtf, maxLen);
if(ret == -1)
{
delete [] pUtf;
return "";
return res;
}
res = pUtf;
delete [] pUtf;