27#if SIZEOF_WCHAR_T == 2
28#define CHARCODE_MAX 0xffff
30#define CHARCODE_MAX 0x10ffff
40inline static utf8proc_ssize_t get_utf8(
const utf8proc_uint8_t *ptr,
42 utf8proc_int32_t *valp) {
43 utf8proc_ssize_t rc = utf8proc_iterate(ptr, n, valp);
45 if (ptr[0] == 0xC0 && ptr[1] == 0x80) {
49 LOCAL_ActiveError->errorNo = REPRESENTATION_ERROR_IN_CHARACTER_CODE;
51 return rc < 1 ? 1 : rc;
54inline static utf8proc_ssize_t put_xutf8(utf8proc_uint8_t *ptr,
55 utf8proc_int32_t val) {
61 utf8proc_ssize_t rc = utf8proc_encode_char(val, ptr);
64 LOCAL_ActiveError->errorNo = REPRESENTATION_ERROR_CHARACTER_CODE;
66 return rc < 1 ? 1 : rc;
70inline static utf8proc_ssize_t put_utf8(utf8proc_uint8_t *ptr,
71 utf8proc_int32_t val) {
72 utf8proc_ssize_t rc = utf8proc_encode_char(val, ptr);
75 LOCAL_ActiveError->errorNo = REPRESENTATION_ERROR_CHARACTER_CODE;
77 return rc < 1 ? 1 : rc;
80inline static const utf8proc_uint8_t *skip_utf8(
const utf8proc_uint8_t *pt,
84 for (i = 0; i < n; i++) {
85 utf8proc_ssize_t l = utf8proc_iterate(pt, -1, &b);
97inline static utf8proc_ssize_t utf8_nof(utf8proc_int32_t val) {
98 return utf8proc_charwidth(val);
101inline static utf8proc_ssize_t strlen_utf8(
const utf8proc_uint8_t *pt) {
102 utf8proc_ssize_t rc = 0;
105 utf8proc_ssize_t l = utf8proc_iterate(pt, -1, &b);
119inline static utf8proc_ssize_t strlen_latin_utf8(
const unsigned char *pt) {
120 utf8proc_ssize_t rc = 0;
123 utf8proc_ssize_t l = utf8proc_encode_char(*pt, &b);
135inline static utf8proc_ssize_t strnlen_latin_utf8(
const unsigned char *pt,
137 utf8proc_ssize_t rc = 0;
140 utf8proc_ssize_t l = utf8proc_encode_char(*pt, &b);
152inline static utf8proc_ssize_t strlen_ucs2_utf8(
const wchar_t *pt) {
153 utf8proc_ssize_t rc = 0;
156 utf8proc_ssize_t l = utf8proc_encode_char(*pt, &b);
167inline static utf8proc_ssize_t strnlen_ucs2_utf8(
const wchar_t *pt,
169 utf8proc_ssize_t rc = 0;
172 utf8proc_ssize_t l = utf8proc_encode_char(*pt, &b);
183inline static int cmpn_utf8(
const utf8proc_uint8_t *pt1,
184 const utf8proc_uint8_t *pt2, utf8proc_ssize_t n) {
187 for (i = 0; i < n; i++) {
188 if (pt1[0] != pt2[0])
189 return pt1[0] - pt2[0];
190 utf8proc_ssize_t l = utf8proc_iterate(pt1, -1, &b);
192 if (pt1[1] != pt2[1])
193 return pt1[1] - pt2[1];
195 if (pt1[2] != pt2[2])
196 return pt1[2] - pt2[2];
198 if (pt1[3] != pt2[3])
199 return pt1[3] - pt2[3];
209#define LEAD_OFFSET ((uint32_t)0xD800 - (uint32_t)(0x10000 >> 10))
210#define SURROGATE_OFFSET \
211 ((uint32_t)0x10000 - (uint32_t)(0xD800 << 10) - (uint32_t)0xDC00)