wide char: remove assert in wideLength and count length all chars separately
This commit is contained in:
@@ -34,9 +34,16 @@ std::wstring ToWString(std::string s)
|
||||
|
||||
size_t wideLength(const std::wstring &ws)
|
||||
{
|
||||
int len = wcswidth(ws.c_str(), -1);
|
||||
assert(len >= 0);
|
||||
return len;
|
||||
size_t result = 0;
|
||||
for (const auto &wc : ws)
|
||||
{
|
||||
int len = wcwidth(wc);
|
||||
if (len < 0)
|
||||
++result;
|
||||
else
|
||||
result += len;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void wideCut(std::wstring &ws, size_t max_length)
|
||||
|
||||
Reference in New Issue
Block a user