【发布时间】:2021-05-25 12:16:30
【问题描述】:
在我正在进行的一个项目中,使用 Embarcadero C++Builder,所有源文件在使用字符串时都使用UnicodeString。
我发现这个 sn-p 可以从 std::wstring 中删除字符:
#include <cctype>
#include <algorithm>
#include <string>
//...
std::wstring FileHandler::removePunctuation(std::wstring word)
{
word.erase(std::remove_if(word.begin(), word.end(),
[](char ch){ return !::iswalnum(ch); }), word.end());
return word;
}
但是如何将相同的算法应用于UnicodeString?或者,在实现中是否有类似的功能?
【问题讨论】: