mirror of
https://github.com/yanyiwu/cppjieba.git
synced 2025-07-18 00:00:12 +08:00
update str_functs.cpp
This commit is contained in:
parent
48136abbd8
commit
28c3260d4c
@ -27,18 +27,18 @@ namespace CPPCOMMON
|
|||||||
|
|
||||||
string joinStr(const vector<string>& src, const string& connectorStr)
|
string joinStr(const vector<string>& src, const string& connectorStr)
|
||||||
{
|
{
|
||||||
string res;
|
string res = "";
|
||||||
string tmpStr;
|
int len = src.size();
|
||||||
size_t len = src.size();
|
if(0 == len)
|
||||||
for(size_t i = 0; i < len - 1; i++)
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
for(int i = 0; i < len - 1; i++)
|
||||||
{
|
{
|
||||||
res += stripStr(src[i]);
|
res += stripStr(src[i]);
|
||||||
res += connectorStr;
|
res += connectorStr;
|
||||||
}
|
}
|
||||||
if(0 < len)
|
res += stripStr(src[len-1]);
|
||||||
{
|
|
||||||
res += stripStr(src[len-1]);
|
|
||||||
}
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
vector<string> splitStr(const string& source, const string& pattern)
|
vector<string> splitStr(const string& source, const string& pattern)
|
||||||
@ -362,7 +362,11 @@ int main()
|
|||||||
string utfStr = unicodeToUtf8(uniStr);
|
string utfStr = unicodeToUtf8(uniStr);
|
||||||
cout<<utfStr<<endl;
|
cout<<utfStr<<endl;
|
||||||
}
|
}
|
||||||
getchar();
|
vector<string> tmp;
|
||||||
|
tmp.push_back("1");
|
||||||
|
//tmp.push_back("2");
|
||||||
|
//tmp.clear();
|
||||||
|
cout<<joinStr(tmp, ",")<<endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user