From 6e22a10eb72b256c437a3a89f9e8309bf2c7ba84 Mon Sep 17 00:00:00 2001 From: ArthurSonzogni Date: Wed, 25 Mar 2020 02:01:31 +0100 Subject: [PATCH] Fix compile error on OS where char is signed. --- src/ftxui/component/event.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/ftxui/component/event.cpp b/src/ftxui/component/event.cpp index ec03648..a4c08df 100644 --- a/src/ftxui/component/event.cpp +++ b/src/ftxui/component/event.cpp @@ -38,14 +38,13 @@ Event Event::Special(const std::string& input) { void ParseUTF8(Receiver& in, Sender& out, std::string& input) { char c; - char mask = 0b11000000; - for (int i = 0; i < 3; ++i) { - if ((input[0] & mask) == mask) { - if (!in->Receive(&c)) - return; - input += c; - } - mask = mask >> 1 | 0b10000000; + unsigned char head = static_cast(input[0]); + for (int i = 0; i < 3; ++i, head <<= 1) { + if ((head & 0b11000000) != 0b11000000) + break; + if (!in->Receive(&c)) + return; + input += c; } out->Send(Event::Character(input)); }