From 2f50a9ea1f4a737f8c11d58dadbe4ce35aa32f8b Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Sat, 21 Nov 2020 22:37:16 +0100 Subject: [PATCH] utf: fix utf32_to_str --- vlib/builtin/utf8.v | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vlib/builtin/utf8.v b/vlib/builtin/utf8.v index 462cfa05bf..16ea26463b 100644 --- a/vlib/builtin/utf8.v +++ b/vlib/builtin/utf8.v @@ -23,18 +23,18 @@ pub fn utf32_to_str_no_malloc(code u32, buf voidptr) string { buffer[0] = byte(icode) res = tos(buffer, 1) } - if icode <= 2047 { /* 0x7FF */ + else if icode <= 2047 { /* 0x7FF */ buffer[0] = 192 | byte(icode>>6) /* 0xC0 - 110xxxxx */ buffer[1] = 128 | byte(icode & 63) /* 0x80 - 0x3F - 10xxxxxx */ res = tos(buffer, 2) } - if icode <= 65535 { /* 0xFFFF */ + else if icode <= 65535 { /* 0xFFFF */ buffer[0] = 224 | byte(icode>>12)/* 0xE0 - 1110xxxx */ buffer[1] = 128 | (byte(icode>>6) & 63) /* 0x80 - 0x3F - 10xxxxxx */ buffer[2] = 128 | byte(icode & 63) /* 0x80 - 0x3F - 10xxxxxx */ res = tos(buffer, 3) } - if icode <= 1114111/* 0x10FFFF */ { + else if icode <= 1114111/* 0x10FFFF */ { buffer[0] = 240 | byte(icode>>18) /* 0xF0 - 11110xxx */ buffer[1] = 128 | (byte(icode>>12) & 63) /* 0x80 - 0x3F - 10xxxxxx */ buffer[2] = 128 | (byte(icode>>6) & 63) /* 0x80 - 0x3F - 10xxxxxx */