51 memmove(&s[start], &s[next], strlen(&s[next]) + 1);
52 return (next - start);
69 const int tail = strlen(&s[pos]) + 1;
74 if (pos + tail + utf8len > n)
78 memmove(&s[pos + utf8len], &s[pos], tail);
82 }
else if (c <= 0x7ff) {
83 s[pos] = 0xc0 | (c >> 6);
84 s[pos + 1] = 0x80 | (c & 0x3f);
85 }
else if (c <= 0xffff) {
86 s[pos] = 0xe0 | (c >> 12);
87 s[pos + 1] = 0x80 | ((c >> 6) & 0x3f);
88 s[pos + 2] = 0x80 | (c & 0x3f);
89 }
else if (c <= 0x10ffff) {
90 s[pos] = 0xf0 | (c >> 18);
91 s[pos + 1] = 0x80 | ((c >> 12) & 0x3f);
92 s[pos + 2] = 0x80 | ((c >> 6) & 0x3f);
93 s[pos + 3] = 0x80 | (c & 0x3f);
136 const char* s = *str;
141 const unsigned char*
buf = (
const unsigned char*)(s);
147 }
else if (buf[0] < 0xC0) {
149 }
else if (buf[0] < 0xE0) {
153 }
else if (buf[0] < 0xF0) {
157 }
else if (buf[0] < 0xF8) {
159 min = 1 << (4 + 6 + 6);
165 for (i = 1; i <
len; i++) {
168 cp = (cp << 6) | (buf[i] & 0x3F);
174 if (0xD800 <= cp && cp <= 0xDFFF)
211 while (str[0] !=
'\0') {
231 while (pos > 0 && str[0] !=
'\0') {
251 length = strlen(src);
252 if (length > limit - 1) {
254 if (length > 0 && (
unsigned char) src[length - 1] >= 0x80) {
255 size_t i = length - 1;
263 memcpy(dest, src, length);
int UTF8_char_offset_to_byte_offset(char *str, int pos)
Convert UTF-8 character offset to a byte offset in the given string.
size_t UTF8_strlen(const char *str)
Count the number of character (not the number of bytes) of a zero termination string.
char * UTF8_strncpyz(char *dest, const char *src, size_t limit)
UTF8 capable string copy function.
int UTF8_char_len(unsigned char c)
length of UTF-8 character starting with this byte.
int UTF8_next(const char **str)
Get the next utf-8 character from the given string.
#define UTF8_CONTINUATION_BYTE(c)
int UTF8_delete_char_at(char *s, int pos)
Delete a whole (possibly multibyte) character from a string.
QGL_EXTERN GLuint GLsizei GLsizei * length
int UTF8_insert_char_at(char *s, int n, int pos, int c)
Insert a (possibly multibyte) UTF-8 character into a string.
int UTF8_encoded_len(int c)
QGL_EXTERN GLenum GLuint * dest
QGL_EXTERN GLuint GLchar GLuint * len