Added support for bigger codepoints in xs_utf8_enc().

This commit is contained in:
default 2022-09-20 07:21:47 +02:00
parent b97f4c7a90
commit 0b69c9abe1
2 changed files with 7 additions and 1 deletions

View File

@ -171,6 +171,13 @@ d_char *xs_utf8_enc(d_char *str, unsigned int cpoint)
tmp[n++] = 0x80 | ((cpoint >> 6) & 0x3f);
tmp[n++] = 0x80 | (cpoint & 0x3f);
}
else
if (cpoint < 0x200000) {
tmp[n++] = 0xf0 | (cpoint >> 18);
tmp[n++] = 0x80 | ((cpoint >> 12) & 0x3f);
tmp[n++] = 0x80 | ((cpoint >> 6) & 0x3f);
tmp[n++] = 0x80 | (cpoint & 0x3f);
}
return xs_append_m(str, (char *)tmp, n);
}

View File

@ -244,7 +244,6 @@ d_char *_xs_json_loads_lexer(const char **json, js_type *t)
s += 3;
tmp[4] = '\0';
xs_debug();
sscanf(tmp, "%04x", &i);
if (i >= 0xd800 && i <= 0xdfff) {