fix jsonb multibyte character invisible problem
This commit is contained in:
@ -2107,7 +2107,7 @@ void escape_json(StringInfo buf, const char *str)
|
||||
appendStringInfo(buf, "\\u%04x", (int) *p);
|
||||
} else {
|
||||
for (int i = 0; i < charlen; i++) {
|
||||
appendStringInfoCharMacro(buf, *p);
|
||||
appendStringInfoCharMacro(buf, *(p + i));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@ -79,6 +79,12 @@ SELECT '"\uaBcD"'::json; -- OK, uppercase and lower case both OK
|
||||
"\uaBcD"
|
||||
(1 row)
|
||||
|
||||
SELECT '"哈1哈"'::jsonb; -- OK
|
||||
jsonb
|
||||
---------
|
||||
"哈1哈"
|
||||
(1 row)
|
||||
|
||||
-- Numbers.
|
||||
SELECT '1'::json; -- OK
|
||||
json
|
||||
|
||||
@ -73,6 +73,12 @@ SELECT '"\u0000"'::jsonb; -- OK, legal escape
|
||||
"\\u0000"
|
||||
(1 row)
|
||||
|
||||
SELECT '"哈1哈"'::jsonb; -- OK
|
||||
jsonb
|
||||
---------
|
||||
"哈1哈"
|
||||
(1 row)
|
||||
|
||||
-- use octet_length here so we don't get an odd unicode char in the
|
||||
-- output
|
||||
SELECT octet_length('"\uaBcD"'::jsonb::text); -- OK, uppercase and lower case both OK
|
||||
|
||||
@ -12,6 +12,7 @@ SELECT '"\u00"'::json; -- ERROR, incomplete escape
|
||||
SELECT '"\u000g"'::json; -- ERROR, g is not a hex digit
|
||||
SELECT '"\u0000"'::json; -- OK, legal escape
|
||||
SELECT '"\uaBcD"'::json; -- OK, uppercase and lower case both OK
|
||||
SELECT '"哈1哈"'::jsonb; -- OK
|
||||
|
||||
-- Numbers.
|
||||
SELECT '1'::json; -- OK
|
||||
|
||||
@ -11,6 +11,7 @@ SELECT '"\u"'::jsonb; -- ERROR, incomplete escape
|
||||
SELECT '"\u00"'::jsonb; -- ERROR, incomplete escape
|
||||
SELECT '"\u000g"'::jsonb; -- ERROR, g is not a hex digit
|
||||
SELECT '"\u0000"'::jsonb; -- OK, legal escape
|
||||
SELECT '"哈1哈"'::jsonb; -- OK
|
||||
-- use octet_length here so we don't get an odd unicode char in the
|
||||
-- output
|
||||
SELECT octet_length('"\uaBcD"'::jsonb::text); -- OK, uppercase and lower case both OK
|
||||
|
||||
Reference in New Issue
Block a user