summaryrefslogtreecommitdiff
path: root/firmware/common
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/common')
-rw-r--r--firmware/common/unicode.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/firmware/common/unicode.c b/firmware/common/unicode.c
index 83780393d5..1dc7eedc3e 100644
--- a/firmware/common/unicode.c
+++ b/firmware/common/unicode.c
@@ -170,11 +170,11 @@ unsigned char* iso_decode(const unsigned char *iso, unsigned char *utf8,
170 170
171/* Recode a UTF-16 string with little-endian byte ordering to UTF-8 */ 171/* Recode a UTF-16 string with little-endian byte ordering to UTF-8 */
172unsigned char* utf16LEdecode(const unsigned char *utf16, unsigned char *utf8, 172unsigned char* utf16LEdecode(const unsigned char *utf16, unsigned char *utf8,
173 unsigned int count) 173 int count)
174{ 174{
175 unsigned long ucs; 175 unsigned long ucs;
176 176
177 while (count != 0) { 177 while (count > 0) {
178 /* Check for a surrogate pair */ 178 /* Check for a surrogate pair */
179 if (utf16[1] >= 0xD8 && utf16[1] < 0xE0) { 179 if (utf16[1] >= 0xD8 && utf16[1] < 0xE0) {
180 ucs = 0x10000 + ((utf16[0] << 10) | ((utf16[1] - 0xD8) << 18) 180 ucs = 0x10000 + ((utf16[0] << 10) | ((utf16[1] - 0xD8) << 18)
@@ -193,11 +193,11 @@ unsigned char* utf16LEdecode(const unsigned char *utf16, unsigned char *utf8,
193 193
194/* Recode a UTF-16 string with big-endian byte ordering to UTF-8 */ 194/* Recode a UTF-16 string with big-endian byte ordering to UTF-8 */
195unsigned char* utf16BEdecode(const unsigned char *utf16, unsigned char *utf8, 195unsigned char* utf16BEdecode(const unsigned char *utf16, unsigned char *utf8,
196 unsigned int count) 196 int count)
197{ 197{
198 unsigned long ucs; 198 unsigned long ucs;
199 199
200 while (count != 0) { 200 while (count > 0) {
201 if (*utf16 >= 0xD8 && *utf16 < 0xE0) { /* Check for a surrogate pair */ 201 if (*utf16 >= 0xD8 && *utf16 < 0xE0) { /* Check for a surrogate pair */
202 ucs = 0x10000 + (((utf16[0] - 0xD8) << 18) | (utf16[1] << 10) 202 ucs = 0x10000 + (((utf16[0] - 0xD8) << 18) | (utf16[1] << 10)
203 | ((utf16[2] - 0xDC) << 8) | utf16[3]); 203 | ((utf16[2] - 0xDC) << 8) | utf16[3]);