diff options
author | default <nobody@localhost> | 2023-11-17 03:51:04 +0100 |
---|---|---|
committer | default <nobody@localhost> | 2023-11-17 03:51:04 +0100 |
commit | acf3cdcf80da7c3443e202a02d4b626c13e9e8dd (patch) | |
tree | f9498dfd051d469d9e76c4b47c5704bfc9a79e48 /xs_json.h | |
parent | 57ab8df0076ba8d57dce16fdd3a5e38c744e1a04 (diff) |
Backport from xs.
Diffstat (limited to 'xs_json.h')
-rw-r--r-- | xs_json.h | 12 |
1 files changed, 4 insertions, 8 deletions
@@ -248,24 +248,20 @@ static xs_val *_xs_json_load_lexer(FILE *f, js_type *t) break; } - if (cp >= 0xd800 && cp <= 0xdfff) { - /* it's a surrogate pair */ - cp = (cp & 0x3ff) << 10; - + if (xs_is_surrogate(cp)) { /* \u must follow */ if (fgetc(f) != '\\' || fgetc(f) != 'u') { *t = JS_ERROR; break; } - unsigned int i; - if (fscanf(f, "%04x", &i) != 1) { + unsigned int p2; + if (fscanf(f, "%04x", &p2) != 1) { *t = JS_ERROR; break; } - cp |= (i & 0x3ff); - cp += 0x10000; + cp = xs_surrogate_dec(cp, p2); } /* replace dangerous control codes with their visual representations */ |