Commit d58bb28a authored by Chen Bill's avatar Chen Bill

DecodeUTF8: use unsigned operand

parent 2b868086
......@@ -98,16 +98,16 @@ public:
const char* p = src;
wchar_t* wp = wstr;
while(*p != 0) {
if((*p & 0x80) == 0) {
if(((unsigned)*p & 0x80) == 0) {
*wp = *p;
p++;
} else if((*p & 0xe0) == 0xc0) {
} else if(((unsigned)*p & 0xe0) == 0xc0) {
*wp = (((unsigned)p[0] & 0x1f) << 6) | ((unsigned)p[1] & 0x3f);
p += 2;
} else if((*p & 0xf0) == 0xe0) {
} else if(((unsigned)*p & 0xf0) == 0xe0) {
*wp = (((unsigned)p[0] & 0xf) << 12) | (((unsigned)p[1] & 0x3f) << 6) | ((unsigned)p[2] & 0x3f);
p += 3;
} else if((*p & 0xf8) == 0xf0) {
} else if(((unsigned)*p & 0xf8) == 0xf0) {
if (sizeof(wchar_t) == 2) {
unsigned unicode = (((unsigned)p[0] & 0x7) << 18) | (((unsigned)p[1] & 0x3f) << 12) | (((unsigned)p[2] & 0x3f) << 6) | ((unsigned)p[3] & 0x3f);
unicode -= 0x10000;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment