From 279321fa7396fff13ce1ea9d555c895b15be539c Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Wed, 23 Feb 2022 20:35:22 +0100 Subject: [PATCH] ime: fix utf8_size for the NUL character --- src/ime.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ime.cpp b/src/ime.cpp index cd36af5..e95467b 100644 --- a/src/ime.cpp +++ b/src/ime.cpp @@ -29,7 +29,9 @@ static const uint32_t UTF8_INVALID = 0xFFFD; static size_t utf8_size(const char *str) { uint8_t u8 = (uint8_t)str[0]; - if ((u8 & 0x80) == 0) { + if (u8 == 0) { + return 0; + } else if ((u8 & 0x80) == 0) { return 1; } else if ((u8 & 0xE0) == 0xC0) { return 2;