libdrawtext
diff src/utf8.c @ 55:59e5858de836
fixed a bug in utf-8 decoding
author | John Tsiombikas <nuclear@mutantstargoat.com> |
---|---|
date | Thu, 15 Sep 2011 23:32:39 +0300 |
parents | bfe431dd1d80 |
children | 17fed026b24b |
line diff
1.1 --- a/src/utf8.c Thu Sep 15 13:56:54 2011 +0300 1.2 +++ b/src/utf8.c Thu Sep 15 23:32:39 2011 +0300 1.3 @@ -9,7 +9,7 @@ 1.4 0xf, /* three-bytes, 4 bits valid */ 1.5 0x7 /* four-bytes, 3 bits valid */ 1.6 }; 1.7 -static const char first_shift[] = { 7, 5, 4, 3 }; /* see above */ 1.8 +static const char first_shift[] = { 0, 7, 5, 4, 3 }; /* see above */ 1.9 1.10 #define CONT_PREFIX 0x80 1.11 #define CONT_MASK 0x3f 1.12 @@ -30,7 +30,7 @@ 1.13 int dtx_utf8_char_code(const char *str) 1.14 { 1.15 int i, nbytes, shift, code = 0; 1.16 - char mask; 1.17 + int mask; 1.18 1.19 if(!U8_IS_FIRST(*str)) { 1.20 return -1; 1.21 @@ -47,9 +47,10 @@ 1.22 1.23 code = (code << shift) | (*str++ & mask); 1.24 mask = 0x3f; 1.25 - shift = i == 0 ? first_shift[nbytes] : 6; 1.26 + shift = 6; 1.27 } 1.28 1.29 + printf("code: %x\n", code); 1.30 return code; 1.31 } 1.32