json.c: fix utf-16 surrogate pair range - json2tsv - JSON to TSV converter | |
git clone git://git.codemadness.org/json2tsv | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit b65bd5139faec35430d342dbce6c3b4bf802f4a8 | |
parent 8128e7fa5d865ac7adff28e7ffb732f0b3b61f58 | |
Author: Hiltjo Posthuma <[email protected]> | |
Date: Fri, 22 Jan 2021 00:23:19 +0100 | |
json.c: fix utf-16 surrogate pair range | |
Test-case of a high codepoint: U+10FFFD. | |
Previously incorrect: | |
printf '%s' '["\udbff\udffd"]' | json2tsv | hexdump -C | |
00000000 09 61 09 0a 5b 5d 09 73 09 ed af bf ed bf bd 0a |.a..[].s........| | |
00000010 | |
Now correct: | |
printf '%s' '["\udbff\udffd"]' | ./json2tsv | hexdump -C | |
00000000 09 61 09 0a 5b 5d 09 73 09 f4 8f bf bd 0a |.a..[].s......| | |
0000000e | |
Diffstat: | |
M json.c | 4 ++-- | |
1 file changed, 2 insertions(+), 2 deletions(-) | |
--- | |
diff --git a/json.c b/json.c | |
@@ -152,8 +152,8 @@ escchr: | |
cp |= (hexdigit(c) << … | |
} | |
/* RFC8259 - 7. Strings - surr… | |
- * 0xd800 - 0xdb7f - high surr… | |
- if (cp >= 0xd800 && cp <= 0xdb… | |
+ * 0xd800 - 0xdbff - high surr… | |
+ if (cp >= 0xd800 && cp <= 0xdb… | |
if ((c = GETNEXT()) !=… | |
len += codepoi… | |
goto chr; |