We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6164470 commit f6c2721Copy full SHA for f6c2721
src/btop_tools.cpp
@@ -222,14 +222,17 @@ namespace Tools {
222
}
223
vector<wchar_t> w_str(w_len);
224
std::mbstowcs(&w_str[0], str_data, w_len);
225
- for (size_t i = 0; i < w_str.size(); i++) {
+ for (size_t i = 0; i < w_str.size() - 1; i++) {
226
if (widechar_wcwidth(w_str[i]) > 1)
227
continue;
228
if (w_str[i] < 0x20)
229
w_str[i] = replacement;
230
231
- str.resize(w_str.size());
232
- std::wcstombs(&str[0], &w_str[0], w_str.size());
+ size_t bytes = std::wcstombs(nullptr, w_str.data(), 0);
+ if (bytes == static_cast<size_t>(-1))
233
+ return str;
234
+ str.resize(bytes);
235
+ std::wcstombs(&str[0], &w_str[0], bytes);
236
237
return str;
238
0 commit comments