23#include "wine/unicode.h"
30 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
31 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
32 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
33 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
34 0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
35 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
36 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
37 3,3,3,3,3,0,0,0,0,0,0,0,0,0,0,0
41static const unsigned char utf8_mask[4] = { 0x7f, 0x1f, 0x0f, 0x07 };
44static const unsigned int utf8_minval[4] = { 0x0, 0x80, 0x800, 0x10000 };
50 if (
src[0] >= 0xd800 &&
src[0] <= 0xdfff)
52 if (
src[0] > 0xdbff ||
54 src[1] < 0xdc00 ||
src[1] > 0xdfff)
56 return 0x10000 + ((
src[0] & 0x3ff) << 10) + (
src[1] & 0x3ff);
111 if (!
len--)
return -1;
118 if ((
len -= 2) < 0)
return -1;
119 dst[1] = 0x80 | (ch & 0x3f);
134 if ((
len -= 3) < 0)
return -1;
135 dst[2] = 0x80 | (
val & 0x3f);
137 dst[1] = 0x80 | (
val & 0x3f);
144 if ((
len -= 4) < 0)
return -1;
145 dst[3] = 0x80 | (
val & 0x3f);
147 dst[2] = 0x80 | (
val & 0x3f);
149 dst[1] = 0x80 | (
val & 0x3f);
167 if (
end > strend)
return ~0;
171 if ((ch =
end[-3] ^ 0x80) >= 0x40)
break;
175 if ((ch =
end[-2] ^ 0x80) >= 0x40)
break;
179 if ((ch =
end[-1] ^ 0x80) >= 0x40)
break;
199 unsigned char ch = *
src++;
216 else if (
res <= 0x10ffff)
241 unsigned char ch = *
src++;
244 if (
dst >= dstend)
return -1;
245 *
dst++ = composed[0] = ch;
255 dst[-1] = composed[0];
259 if (
dst >= dstend)
return -1;
260 *
dst++ = composed[0] =
res;
262 else if (
res <= 0x10ffff)
264 if (
dst >= dstend - 1)
return -1;
266 *
dst++ = 0xd800 | (
res >> 10);
267 *
dst++ = 0xdc00 | (
res & 0x3ff);
285 unsigned char ch = *
src++;
314 while ((
dst < dstend) && (
src < srcend))
316 unsigned char ch = *
src++;
326 else if (
res <= 0x10ffff)
328 if (
dst == dstend - 1)
return -1;
330 *
dst++ = 0xd800 | (
res >> 10);
331 *
dst++ = 0xdc00 | (
res & 0x3ff);
336 if (
src < srcend)
return -1;
#define WC_ERR_INVALID_CHARS
#define MB_ERR_INVALID_CHARS
static DWORD LPDWORD LPCSTR DWORD srclen