… | |
… | |
759 | : enc.json.flags & F_LATIN1 ? 0x000100UL |
759 | : enc.json.flags & F_LATIN1 ? 0x000100UL |
760 | : 0x110000UL; |
760 | : 0x110000UL; |
761 | |
761 | |
762 | SvPOK_only (enc.sv); |
762 | SvPOK_only (enc.sv); |
763 | encode_sv (&enc, scalar); |
763 | encode_sv (&enc, scalar); |
|
|
764 | encode_nl (&enc); |
764 | |
765 | |
765 | SvCUR_set (enc.sv, enc.cur - SvPVX (enc.sv)); |
766 | SvCUR_set (enc.sv, enc.cur - SvPVX (enc.sv)); |
766 | *SvEND (enc.sv) = 0; // many xs functions expect a trailing 0 for text strings |
767 | *SvEND (enc.sv) = 0; // many xs functions expect a trailing 0 for text strings |
767 | |
768 | |
768 | if (!(enc.json.flags & (F_ASCII | F_LATIN1 | F_UTF8))) |
769 | if (!(enc.json.flags & (F_ASCII | F_LATIN1 | F_UTF8))) |
… | |
… | |
948 | else if (expect_true (ch >= 0x20 && ch < 0x80)) |
949 | else if (expect_true (ch >= 0x20 && ch < 0x80)) |
949 | *cur++ = ch; |
950 | *cur++ = ch; |
950 | else if (ch >= 0x80) |
951 | else if (ch >= 0x80) |
951 | { |
952 | { |
952 | STRLEN clen; |
953 | STRLEN clen; |
953 | UV uch; |
|
|
954 | |
954 | |
955 | --dec_cur; |
955 | --dec_cur; |
956 | |
956 | |
957 | uch = decode_utf8 (dec_cur, dec->end - dec_cur, &clen); |
957 | decode_utf8 (dec_cur, dec->end - dec_cur, &clen); |
958 | if (clen == (STRLEN)-1) |
958 | if (clen == (STRLEN)-1) |
959 | ERR ("malformed UTF-8 character in JSON string"); |
959 | ERR ("malformed UTF-8 character in JSON string"); |
960 | |
960 | |
961 | do |
961 | do |
962 | *cur++ = *dec_cur++; |
962 | *cur++ = *dec_cur++; |