… | |
… | |
17 | // guarantees, though. if it breaks, you get to keep the pieces. |
17 | // guarantees, though. if it breaks, you get to keep the pieces. |
18 | #ifndef UTF8_MAXBYTES |
18 | #ifndef UTF8_MAXBYTES |
19 | # define UTF8_MAXBYTES 13 |
19 | # define UTF8_MAXBYTES 13 |
20 | #endif |
20 | #endif |
21 | |
21 | |
|
|
22 | // three extra for rounding, sign, and end of string |
22 | #define IVUV_MAXCHARS (sizeof (UV) * CHAR_BIT * 28 / 93 + 2) |
23 | #define IVUV_MAXCHARS (sizeof (UV) * CHAR_BIT * 28 / 93 + 3) |
23 | |
24 | |
24 | #define F_ASCII 0x00000001UL |
25 | #define F_ASCII 0x00000001UL |
25 | #define F_LATIN1 0x00000002UL |
26 | #define F_LATIN1 0x00000002UL |
26 | #define F_UTF8 0x00000004UL |
27 | #define F_UTF8 0x00000004UL |
27 | #define F_INDENT 0x00000008UL |
28 | #define F_INDENT 0x00000008UL |
… | |
… | |
949 | else if (expect_true (ch >= 0x20 && ch < 0x80)) |
950 | else if (expect_true (ch >= 0x20 && ch < 0x80)) |
950 | *cur++ = ch; |
951 | *cur++ = ch; |
951 | else if (ch >= 0x80) |
952 | else if (ch >= 0x80) |
952 | { |
953 | { |
953 | STRLEN clen; |
954 | STRLEN clen; |
954 | UV uch; |
|
|
955 | |
955 | |
956 | --dec_cur; |
956 | --dec_cur; |
957 | |
957 | |
958 | uch = decode_utf8 (dec_cur, dec->end - dec_cur, &clen); |
958 | decode_utf8 (dec_cur, dec->end - dec_cur, &clen); |
959 | if (clen == (STRLEN)-1) |
959 | if (clen == (STRLEN)-1) |
960 | ERR ("malformed UTF-8 character in JSON string"); |
960 | ERR ("malformed UTF-8 character in JSON string"); |
961 | |
961 | |
962 | do |
962 | do |
963 | *cur++ = *dec_cur++; |
963 | *cur++ = *dec_cur++; |