Commit b8480c3b authored by Chen Bill's avatar Chen Bill

format

parent 76bd5002
...@@ -67,33 +67,33 @@ public: ...@@ -67,33 +67,33 @@ public:
if (pstr - str + codepoint_size > size - 1) if (pstr - str + codepoint_size > size - 1)
break; break;
switch (codepoint_size) { switch (codepoint_size) {
case 1: case 1:
*pstr = (char)cur; *pstr = (char)cur;
break; break;
case 2: case 2:
pstr[0] = ((cur >> 6) & 0x1f) | 0xc0; pstr[0] = ((cur >> 6) & 0x1f) | 0xc0;
pstr[1] = (cur & 0x3f) | 0x80; pstr[1] = (cur & 0x3f) | 0x80;
break; break;
case 3: case 3:
pstr[0] = ((cur >> 12) & 0xf) | 0xe0; pstr[0] = ((cur >> 12) & 0xf) | 0xe0;
pstr[1] = ((cur >> 6) & 0x3f) | 0x80; pstr[1] = ((cur >> 6) & 0x3f) | 0x80;
pstr[2] = (cur & 0x3f) | 0x80; pstr[2] = (cur & 0x3f) | 0x80;
break; break;
case 4: case 4:
if (sizeof(wchar_t) == 2) { if (sizeof(wchar_t) == 2) {
cur = 0; cur = 0;
cur |= ((unsigned)*wsrc & 0x3ff) << 10; cur |= ((unsigned)*wsrc & 0x3ff) << 10;
++wsrc; ++wsrc;
cur |= (unsigned)*wsrc & 0x3ff; cur |= (unsigned)*wsrc & 0x3ff;
cur += 0x10000; cur += 0x10000;
} }
pstr[0] = ((cur >> 18) & 0x7) | 0xf0; pstr[0] = ((cur >> 18) & 0x7) | 0xf0;
pstr[1] = ((cur >> 12) & 0x3f) | 0x80; pstr[1] = ((cur >> 12) & 0x3f) | 0x80;
pstr[2] = ((cur >> 6) & 0x3f) | 0x80; pstr[2] = ((cur >> 6) & 0x3f) | 0x80;
pstr[3] = (cur & 0x3f) | 0x80; pstr[3] = (cur & 0x3f) | 0x80;
break; break;
default: default:
break; break;
} }
pstr += codepoint_size; pstr += codepoint_size;
wsrc++; wsrc++;
......
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