Lines Matching refs:uc

116   utf8proc_uint32_t uc;
122 uc = *str++;
123 if (uc < 0x80) {
124 *dst = uc;
128 if ((uc - 0xc2) > (0xf4-0xc2)) return UTF8PROC_ERROR_INVALIDUTF8;
129 if (uc < 0xe0) { /* 2-byte sequence */
132 *dst = ((uc & 0x1f)<<6) | (*str & 0x3f);
135 if (uc < 0xf0) { /* 3-byte sequence */
139 if (uc == 0xed && *str > 0x9f)
141 uc = ((uc & 0xf)<<12) | ((*str & 0x3f)<<6) | (str[1] & 0x3f);
142 if (uc < 0x800)
144 *dst = uc;
152 if (uc == 0xf0) {
154 } else if (uc == 0xf4) {
157 *dst = ((uc & 7)<<18) | ((*str & 0x3f)<<12) | ((str[1] & 0x3f)<<6) | (str[2] & 0x3f);
161 UTF8PROC_DLLEXPORT utf8proc_bool utf8proc_codepoint_valid(utf8proc_int32_t uc) {
162 return (((utf8proc_uint32_t)uc)-0xd800 > 0x07ff) && ((utf8proc_uint32_t)uc < 0x110000);
165 UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_encode_char(utf8proc_int32_t uc, utf8proc_uint8_t *dst) {
166 if (uc < 0x00) {
168 } else if (uc < 0x80) {
169 dst[0] = (utf8proc_uint8_t) uc;
171 } else if (uc < 0x800) {
172 dst[0] = (utf8proc_uint8_t)(0xC0 + (uc >> 6));
173 dst[1] = (utf8proc_uint8_t)(0x80 + (uc & 0x3F));
177 } else if (uc < 0x10000) {
178 dst[0] = (utf8proc_uint8_t)(0xE0 + (uc >> 12));
179 dst[1] = (utf8proc_uint8_t)(0x80 + ((uc >> 6) & 0x3F));
180 dst[2] = (utf8proc_uint8_t)(0x80 + (uc & 0x3F));
182 } else if (uc < 0x110000) {
183 dst[0] = (utf8proc_uint8_t)(0xF0 + (uc >> 18));
184 dst[1] = (utf8proc_uint8_t)(0x80 + ((uc >> 12) & 0x3F));
185 dst[2] = (utf8proc_uint8_t)(0x80 + ((uc >> 6) & 0x3F));
186 dst[3] = (utf8proc_uint8_t)(0x80 + (uc & 0x3F));
191 /* internal "unsafe" version that does not check whether uc is in range */
192 static utf8proc_ssize_t unsafe_encode_char(utf8proc_int32_t uc, utf8proc_uint8_t *dst) {
193 if (uc < 0x00) {
195 } else if (uc < 0x80) {
196 dst[0] = (utf8proc_uint8_t)uc;
198 } else if (uc < 0x800) {
199 dst[0] = (utf8proc_uint8_t)(0xC0 + (uc >> 6));
200 dst[1] = (utf8proc_uint8_t)(0x80 + (uc & 0x3F));
202 } else if (uc == 0xFFFF) {
205 } else if (uc == 0xFFFE) {
208 } else if (uc < 0x10000) {
209 dst[0] = (utf8proc_uint8_t)(0xE0 + (uc >> 12));
210 dst[1] = (utf8proc_uint8_t)(0x80 + ((uc >> 6) & 0x3F));
211 dst[2] = (utf8proc_uint8_t)(0x80 + (uc & 0x3F));
213 } else if (uc < 0x110000) {
214 dst[0] = (utf8proc_uint8_t)(0xF0 + (uc >> 18));
215 dst[1] = (utf8proc_uint8_t)(0x80 + ((uc >> 12) & 0x3F));
216 dst[2] = (utf8proc_uint8_t)(0x80 + ((uc >> 6) & 0x3F));
217 dst[3] = (utf8proc_uint8_t)(0x80 + (uc & 0x3F));
222 /* internal "unsafe" version that does not check whether uc is in range */
223 static const utf8proc_property_t *unsafe_get_property(utf8proc_int32_t uc) {
224 /* ASSERT: uc >= 0 && uc < 0x110000 */
227 utf8proc_stage1table[uc >> 8] + (uc & 0xFF)
232 UTF8PROC_DLLEXPORT const utf8proc_property_t *utf8proc_get_property(utf8proc_int32_t uc) {
233 return uc < 0 || uc >= 0x110000 ? utf8proc_properties : unsafe_get_property(uc);
399 UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_decompose_char(utf8proc_int32_t uc, utf8proc_int32_t *dst, utf8proc_ssize_t bufsize, utf8proc_option_t options, int *last_boundclass) {
403 if (uc < 0 || uc >= 0x110000) return UTF8PROC_ERROR_NOTASSIGNED;
404 property = unsafe_get_property(uc);
406 hangul_sindex = uc - UTF8PROC_HANGUL_SBASE;
430 if (uc == 0x2018 || uc == 0x2019 || uc == 0x02BC || uc == 0x02C8)
432 if (category == UTF8PROC_CATEGORY_PD || uc == 0x2212)
434 if (uc == 0x2044 || uc == 0x2215) utf8proc_decompose_lump(0x002F);
435 if (uc == 0x2236) utf8proc_decompose_lump(0x003A);
436 if (uc == 0x2039 || uc == 0x2329 || uc == 0x3008)
438 if (uc == 0x203A || uc == 0x232A || uc == 0x3009)
440 if (uc == 0x2216) utf8proc_decompose_lump(0x005C);
441 if (uc == 0x02C4 || uc == 0x02C6 || uc == 0x2038 || uc == 0x2303)
443 if (category == UTF8PROC_CATEGORY_PC || uc == 0x02CD)
445 if (uc == 0x02CB) utf8proc_decompose_lump(0x0060);
446 if (uc == 0x2223) utf8proc_decompose_lump(0x007C);
447 if (uc == 0x223C) utf8proc_decompose_lump(0x007E);
476 if (bufsize >= 2) dst[1] = uc;
480 if (bufsize >= 1) *dst = uc;
504 utf8proc_int32_t uc;
510 rpos += utf8proc_iterate(str + rpos, -1, &uc);
512 as 'uc' is < 0 in case of error */
513 if (uc < 0) return UTF8PROC_ERROR_INVALIDUTF8;
515 if (uc == 0) break;
518 rpos += utf8proc_iterate(str + rpos, strlen - rpos, &uc);
519 if (uc < 0) return UTF8PROC_ERROR_INVALIDUTF8;
522 uc = custom_func(uc, custom_data); /* user-specified custom mapping */
525 uc, buffer + wpos, (bufsize > wpos) ? (bufsize - wpos) : 0, options,
563 utf8proc_int32_t uc;
565 uc = buffer[rpos];
566 if (uc == 0x000D && rpos < length-1 && buffer[rpos+1] == 0x000A) rpos++;
567 if (uc == 0x000A || uc == 0x000D || uc == 0x0085 ||
568 ((options & UTF8PROC_STRIPCC) && (uc == 0x000B || uc == 0x000C))) {
583 (uc < 0x0020 || (uc >= 0x007F && uc < 0x00A0))) {
584 if (uc == 0x0009) buffer[wpos++] = 0x0020;
586 buffer[wpos++] = uc;
677 utf8proc_int32_t uc;
680 uc = buffer[rpos];
681 wpos += unsafe_encode_char(uc, ((utf8proc_uint8_t *)buffer) + wpos);
685 uc = buffer[rpos];
686 wpos += utf8proc_encode_char(uc, ((utf8proc_uint8_t *)buffer) + wpos);