# HG changeset patch # User Adam Chlipala # Date 1281470575 14400 # Node ID 829da30fb808117d39c831ad31727186937a787e # Parent 514be09d5018b18115307a26fd203c195b9b0a5e Fix C-side jsification of UTF-8 strings diff -r 514be09d5018 -r 829da30fb808 src/c/urweb.c --- a/src/c/urweb.c Tue Aug 10 15:55:43 2010 -0400 +++ b/src/c/urweb.c Tue Aug 10 16:02:55 2010 -0400 @@ -1336,7 +1336,7 @@ *s2++ = '"'; for (; *s; s++) { - char c = *s; + unsigned char c = *s; switch (c) { case '"': @@ -1352,7 +1352,7 @@ s2 += 2; break; default: - if (isprint((int)c)) + if (isprint((int)c) || c >= 128) *s2++ = c; else { sprintf(s2, "\\%3o", c); @@ -1366,7 +1366,8 @@ return r; } -uw_Basis_string uw_Basis_jsifyChar(uw_context ctx, uw_Basis_char c) { +uw_Basis_string uw_Basis_jsifyChar(uw_context ctx, uw_Basis_char c1) { + unsigned char c = c1; char *r, *s2; uw_check_heap(ctx, 6); @@ -1388,10 +1389,10 @@ s2 += 2; break; default: - if (isprint((int)c)) + if (isprint((int)c) || c >= 128) *s2++ = c; else { - sprintf(s2, "\\%3o", c); + sprintf(s2, "\\%3o", (unsigned char)c); s2 += 4; } } @@ -1410,7 +1411,7 @@ *s2++ = '"'; for (; *s; s++) { - char c = *s; + unsigned char c = *s; switch (c) { case '\'': @@ -1422,7 +1423,7 @@ s2 += 2; break; default: - if (isprint((int)c)) + if (isprint((int)c) || c >= 128) *s2++ = c; else { sprintf(s2, "\\%3o", c);