UnicodeToUTF8
点击次数:32 次 发布日期:2008-11-27 01:05:01 作者:源代码网
|
{ ASSERT(wstrIn); int wLen=wcslen(wstrIn); int i=0; #define putchar(a) buff[i++]=(BYTE)a; for(int j=0;(DWORD)j<wcslen(wstrIn);j++) { ASSERT(i<vLen); WCHAR c=wstrIn[j]; if (c < 0x80) { putchar (c); } else if (c < 0x800) { putchar (0xC0 | c>>6); putchar (0x80 | c & 0x3F); } else if (c < 0x10000) { putchar (0xE0 | c>>12); putchar (0x80 | c>>6 & 0x3F); putchar (0x80 | c & 0x3F); } else if (c < 0x200000) { putchar (0xF0 | c>>18); putchar (0x80 | c>>12 & 0x3F); putchar (0x80 | c>>6 & 0x3F); putchar (0x80 | c & 0x3F); } }< 源代码网供稿. |
