23{
30
31 if (!uni_src)
33 if (!utf8_bytes_written)
35 if (utf8_dest && uni_bytes %
sizeof(
WCHAR))
37
38 written = 0;
40
41 for (
i = 0;
i < uni_bytes /
sizeof(
WCHAR);
i++)
42 {
43
45 if (ch >= 0xdc00 && ch <= 0xdfff)
46 {
47 ch = 0xfffd;
49 }
50 else if (ch >= 0xd800 && ch <= 0xdbff)
51 {
52 if (
i + 1 < uni_bytes /
sizeof(
WCHAR))
53 {
54 ch -= 0xd800;
55 ch <<= 10;
56 if (uni_src[
i + 1] >= 0xdc00 && uni_src[
i + 1] <= 0xdfff)
57 {
58 ch |= uni_src[
i + 1] - 0xdc00;
59 ch += 0x010000;
61 }
62 else
63 {
64 ch = 0xfffd;
66 }
67 }
68 else
69 {
70 ch = 0xfffd;
72 }
73 }
74
75
77 if (ch < 0x80)
78 {
79 utf8_ch[0] = ch & 0x7f;
80 utf8_ch_len = 1;
81 }
82 else if (ch < 0x800)
83 {
84 utf8_ch[0] = 0xc0 | (ch >> 6 & 0x1f);
85 utf8_ch[1] = 0x80 | (ch >> 0 & 0x3f);
86 utf8_ch_len = 2;
87 }
88 else if (ch < 0x10000)
89 {
90 utf8_ch[0] = 0xe0 | (ch >> 12 & 0x0f);
91 utf8_ch[1] = 0x80 | (ch >> 6 & 0x3f);
92 utf8_ch[2] = 0x80 | (ch >> 0 & 0x3f);
93 utf8_ch_len = 3;
94 }
95 else if (ch < 0x200000)
96 {
97 utf8_ch[0] = 0xf0 | (ch >> 18 & 0x07);
98 utf8_ch[1] = 0x80 | (ch >> 12 & 0x3f);
99 utf8_ch[2] = 0x80 | (ch >> 6 & 0x3f);
100 utf8_ch[3] = 0x80 | (ch >> 0 & 0x3f);
101 utf8_ch_len = 4;
102 }
103
104 if (!utf8_dest)
105 {
106 written += utf8_ch_len;
107 continue;
108 }
109
110 if (utf8_bytes_max >= utf8_ch_len)
111 {
112 memcpy(utf8_dest, utf8_ch, utf8_ch_len);
113 utf8_dest += utf8_ch_len;
114 utf8_bytes_max -= utf8_ch_len;
115 written += utf8_ch_len;
116 }
117 else
118 {
119 utf8_bytes_max = 0;
121 }
122 }
123
124 *utf8_bytes_written = written;
126}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
#define memcpy(s1, s2, n)
#define STATUS_INVALID_PARAMETER_4
#define STATUS_SOME_NOT_MAPPED
#define STATUS_INVALID_PARAMETER_5
#define STATUS_BUFFER_TOO_SMALL
#define STATUS_INVALID_PARAMETER