From 2b5f698c917372ba03e72de9c934f27fb2b94bf2 Mon Sep 17 00:00:00 2001 From: Boris Faure Date: Sat, 13 Jun 2020 00:12:21 +0200 Subject: [PATCH] utf8: avoid implicit signedness conversions --- src/bin/utf8.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/bin/utf8.c b/src/bin/utf8.c index 4dd360f6..9b7b34f6 100644 --- a/src/bin/utf8.c +++ b/src/bin/utf8.c @@ -12,30 +12,30 @@ codepoint_to_utf8(Eina_Unicode g, char *txt) } else if (g < (1 << (5 + 6))) { // 110xxxxx 10xxxxxx - txt[0] = 0xc0 | ((g >> 6) & 0x1f); - txt[1] = 0x80 | ((g ) & 0x3f); + txt[0] = (char)(0xc0 | ((g >> 6) & 0x1f)); + txt[1] = (char)(0x80 | ((g ) & 0x3f)); txt[2] = 0; return 2; } else if (g < (1 << (4 + 6 + 6))) { // 1110xxxx 10xxxxxx 10xxxxxx - txt[0] = 0xe0 | ((g >> 12) & 0x0f); - txt[1] = 0x80 | ((g >> 6 ) & 0x3f); - txt[2] = 0x80 | ((g ) & 0x3f); + txt[0] = (char)(0xe0 | ((g >> 12) & 0x0f)); + txt[1] = (char)(0x80 | ((g >> 6 ) & 0x3f)); + txt[2] = (char)(0x80 | ((g ) & 0x3f)); txt[3] = 0; return 3; } else if (g < (1 << (3 + 6 + 6 + 6))) { // 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx - txt[0] = 0xf0 | ((g >> 18) & 0x07); - txt[1] = 0x80 | ((g >> 12) & 0x3f); - txt[2] = 0x80 | ((g >> 6 ) & 0x3f); - txt[3] = 0x80 | ((g ) & 0x3f); + txt[0] = (char)(0xf0 | ((g >> 18) & 0x07)); + txt[1] = (char)(0x80 | ((g >> 12) & 0x3f)); + txt[2] = (char)(0x80 | ((g >> 6 ) & 0x3f)); + txt[3] = (char)(0x80 | ((g ) & 0x3f)); txt[4] = 0; return 4; } else - { // error - cant encode this in utf8 + { // error - can't encode this in utf8 txt[0] = 0; return 0; }