summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar fab <fabrice.leal.ch@gmail.com>2018-12-06 21:24:04 +0000
committerGravatar fab <fabrice.leal.ch@gmail.com>2018-12-06 21:24:04 +0000
commitdf191c8374991f65c5f5a552cfa5f4fb08fe29e8 (patch)
tree42f8c1d6bae638bf47e2e012dff8feba30e74463 /src
parentbc1547efbbad30da255b7c29973c94c8d37edabc (diff)
chars with more than 2 bytes are awkwardly handled by the "normal" string of javascript. the best way to get consistent results seems to be to convert to array by Array.from(...) and back to strings with .join("")
Diffstat (limited to 'src')
-rw-r--r--src/c/urweb.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/c/urweb.c b/src/c/urweb.c
index d622df87..1394e068 100644
--- a/src/c/urweb.c
+++ b/src/c/urweb.c
@@ -1594,9 +1594,13 @@ void jsifyChar(char**buffer_ptr, uw_context ctx, uw_Basis_char c1) {
buffer += offset;
}
else {
- assert(65536 > c1);
- sprintf(buffer, "\\u%04x", c1);
- buffer += 6;
+ if(65536 > c1) {
+ sprintf(buffer, "\\u%04x", c1);
+ buffer += 6;
+ } else {
+ sprintf(buffer, "\\u{%06x}", c1);
+ buffer += 10;
+ }
}
}
@@ -1608,7 +1612,7 @@ uw_Basis_string uw_Basis_jsifyString(uw_context ctx, uw_Basis_string s) {
char *r, *s2;
uw_Basis_char c;
- uw_check_heap(ctx, strlen(s) * 6 + 3);
+ uw_check_heap(ctx, strlen(s) * 10 + 3);
r = s2 = ctx->heap.front;
*s2++ = '"';
@@ -1632,7 +1636,7 @@ uw_Basis_int uw_Basis_ord(uw_context ctx, uw_Basis_char c);
uw_Basis_string uw_Basis_jsifyChar(uw_context ctx, uw_Basis_char c1) {
char *r, *s2;
- uw_check_heap(ctx, 8);
+ uw_check_heap(ctx, 10);
r = s2 = ctx->heap.front;