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)
|
size_t wideLength(const std::wstring &ws)
|
||||||
{
|
{
|
||||||
int len = wcswidth(ws.c_str(), -1);
|
size_t result = 0;
|
||||||
assert(len >= 0);
|
for (const auto &wc : ws)
|
||||||
return len;
|
{
|
||||||
|
int len = wcwidth(wc);
|
||||||
|
if (len < 0)
|
||||||
|
++result;
|
||||||
|
else
|
||||||
|
result += len;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wideCut(std::wstring &ws, size_t max_length)
|
void wideCut(std::wstring &ws, size_t max_length)
|
||||||
|
|||||||
Reference in New Issue
Block a user