2
-- encoding-sensitive tests for json
5
SELECT '"\u"'::json; -- ERROR, incomplete escape
6
SELECT '"\u00"'::json; -- ERROR, incomplete escape
7
SELECT '"\u000g"'::json; -- ERROR, g is not a hex digit
8
SELECT '"\u0000"'::json; -- OK, legal escape
9
SELECT '"\uaBcD"'::json; -- OK, uppercase and lower case both OK
11
-- handling of unicode surrogate pairs
13
select json '{ "a": "\ud83d\ude04\ud83d\udc36" }' -> 'a' as correct_in_utf8;
14
select json '{ "a": "\ud83d\ud83d" }' -> 'a'; -- 2 high surrogates in a row
15
select json '{ "a": "\ude04\ud83d" }' -> 'a'; -- surrogates in wrong order
16
select json '{ "a": "\ud83dX" }' -> 'a'; -- orphan high surrogate
17
select json '{ "a": "\ude04X" }' -> 'a'; -- orphan low surrogate
19
--handling of simple unicode escapes
21
select json '{ "a": "the Copyright \u00a9 sign" }' ->> 'a' as correct_in_utf8;
22
select json '{ "a": "dollar \u0024 character" }' ->> 'a' as correct_everywhere;
23
select json '{ "a": "null \u0000 escape" }' ->> 'a' as not_escaped;