summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordefault <nobody@localhost>2022-09-20 07:21:47 +0200
committerdefault <nobody@localhost>2022-09-20 07:21:47 +0200
commit0b69c9abe1465c49371b9192262c44aefecbe190 (patch)
tree11c7746079c8e32fd68fe289dd8ad1ed0165a267
parentb97f4c7a90125812b6d17d5b9f2450708e53a4ba (diff)
Added support for bigger codepoints in xs_utf8_enc().
-rw-r--r--xs_encdec.h7
-rw-r--r--xs_json.h1
2 files changed, 7 insertions, 1 deletions
diff --git a/xs_encdec.h b/xs_encdec.h
index e336218..1ca9346 100644
--- a/xs_encdec.h
+++ b/xs_encdec.h
@@ -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);
}
diff --git a/xs_json.h b/xs_json.h
index 75a4e4d..53b1d20 100644
--- a/xs_json.h
+++ b/xs_json.h
@@ -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) {