mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2024-11-26 12:37:06 +08:00
Fixed infinite loop in Screen::ToString() for non-printable chars (#69)
This commit is contained in:
parent
92ec5ab4ca
commit
d0eab41344
@ -164,8 +164,15 @@ std::string Screen::ToString() {
|
||||
auto& pixel = pixels_[y][x];
|
||||
wchar_t c = pixel.character;
|
||||
UpdatePixelStyle(ss, previous_pixel, pixel);
|
||||
|
||||
auto width = wchar_width(c);
|
||||
if (width <= 0) {
|
||||
// Avoid an infinite loop for non-printable characters
|
||||
c = L' ';
|
||||
width = 1;
|
||||
}
|
||||
ss << c;
|
||||
x += wchar_width(c);
|
||||
x += width;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user