34 #define WDL_WCHAR WCHAR
37 #define WDL_WCHAR wchar_t
47 const unsigned char *
p = (
const unsigned char *)rd;
48 const unsigned char b0 = *
p;
49 unsigned char b1,b2,b3;
56 if (((b1=
p[1])&0xC0) != 0x80)
return 1;
60 if (!(b0&0x1E))
return 1;
61 if (cOut) *cOut = ((b0&0x1F)<<6)|(b1&0x3F);
65 if (((b2=
p[2])&0xC0) != 0x80)
return 1;
69 if (!(b0&0xF) && !(b1&0x20))
return 1;
71 if (cOut) *cOut = ((b0&0x0F)<<12)|((b1&0x3F)<<6)|(b2&0x3f);
75 if (((b3=
p[3])&0xC0) != 0x80)
return 1;
79 if (!(b0&0x7) && !(b1&0x30))
return 1;
81 if (cOut) *cOut = ((b0&7)<<18)|((b1&0x3F)<<12)|((b2&0x3F)<<6)|(b3&0x3F);
87 if ((
p[4]&0xC0) != 0x80)
return 1;
90 if (cOut) *cOut =
'_';
94 if ((
p[5]&0xC0) != 0x80)
return 1;
95 if (cOut) *cOut =
'_';
104 if (
c < 0)
return -1;
108 if (dest_len<1)
return 0;
114 if (dest_len < 2)
return 0;
117 dest[1]=0x80|(
c&0x3F);
122 if (dest_len < 3)
return 0;
124 dest[0]=0xE0|(
c>>12);
125 dest[1]=0x80|((
c>>6)&0x3F);
126 dest[2]=0x80|(
c&0x3F);
131 if (dest_len < 4)
return 0;
132 dest[0]=0xF0|(
c>>18);
133 dest[1]=0x80|((
c>>12)&0x3F);
134 dest[2]=0x80|((
c>>6)&0x3F);
135 dest[3]=0x80|(
c&0x3F);
147 if (!dest || destlenbytes < 1)
return 0;
149 if (src)
for (; *src &&
w < dest_endp; )
156 return (
int)(
w-dest);
166 if (destlen == 1) dest[0]=0;
185 char *
p = dest, *dest_endp = dest + destlenbytes - 1;
186 if (!dest || destlenbytes < 1)
return 0;
188 if (src)
while (*src &&
p < dest_endp)
195 else if (
v == 0)
break;
198 return (
int)(
p-dest);
210 const unsigned char c = *(
const unsigned char *)str;
214 if (!
c)
return hasUTF;
215 if (
c >= 0x80)
return -1;
221 if (
l < 2)
return -1;
232 while (charpos-- > 0 && str[bpos])
240 int bpos = 0, cpos=0;
241 while (bpos < bytepos && str[bpos])
249#define WDL_utf8_get_charlen(rd) WDL_utf8_bytepos_to_charpos((rd), 0x7fffffff)
UINT_D64 w
Definition inflate.c:942
int * l
Definition inflate.c:1579
unsigned v[N_MAX]
Definition inflate.c:1584
uch * p
Definition crypt.c:594
return c
Definition crypt.c:175
#define WDL_STATICFUNC_UNUSED
Definition wdltypes.h:87
#define WDL_WCHAR
Definition wdlutf8.h:37
static int WDL_STATICFUNC_UNUSED WDL_utf8_charpos_to_bytepos(const char *str, int charpos)
Definition wdlutf8.h:229
static int WDL_STATICFUNC_UNUSED WDL_MakeUTFChar(char *dest, int c, int destlen)
Definition wdlutf8.h:162
static int WDL_STATICFUNC_UNUSED wdl_utf8_parsechar(const char *rd, int *cOut)
Definition wdlutf8.h:45
static int WDL_STATICFUNC_UNUSED WDL_DetectUTF8(const char *str)
Definition wdlutf8.h:202
static int WDL_STATICFUNC_UNUSED WDL_WideToMBStr(char *dest, const WDL_WCHAR *src, int destlenbytes)
Definition wdlutf8.h:183
static int WDL_STATICFUNC_UNUSED WDL_MBtoWideStr(WDL_WCHAR *dest, const char *src, int destlenbytes)
Definition wdlutf8.h:144
static int WDL_STATICFUNC_UNUSED WDL_utf8_bytepos_to_charpos(const char *str, int bytepos)
Definition wdlutf8.h:238
static int WDL_STATICFUNC_UNUSED wdl_utf8_makechar(int c, char *dest, int dest_len)
Definition wdlutf8.h:102