mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-18 21:29:19 +02:00
Support for \u sequences in JSON
This commit is contained in:
parent
62efe38c70
commit
c448e8b441
1 changed files with 7 additions and 0 deletions
|
@ -57,6 +57,7 @@ sexp parse_json_literal (sexp ctx, sexp self, sexp str, const char* s, int* i, c
|
|||
sexp parse_json_string (sexp ctx, sexp self, sexp str, const char* s, int* i, const int len) {
|
||||
sexp_gc_var2(res, tmp);
|
||||
sexp_gc_preserve2(ctx, res, tmp);
|
||||
char utf_tmp[5];
|
||||
int from = *i, to = *i;
|
||||
res = SEXP_NULL;
|
||||
for ( ; s[to] != '"'; ++to) {
|
||||
|
@ -78,6 +79,12 @@ sexp parse_json_string (sexp ctx, sexp self, sexp str, const char* s, int* i, co
|
|||
res = sexp_cons(ctx, tmp, res);
|
||||
from = to+1;
|
||||
break;
|
||||
case 'u':
|
||||
strncpy(utf_tmp, s+to+1, 5);
|
||||
tmp = sexp_make_string(ctx, sexp_make_fixnum(1), sexp_make_character(strtoll(utf_tmp, NULL, 16)));
|
||||
res = sexp_cons(ctx, tmp, res);
|
||||
from = to+5;
|
||||
break;
|
||||
default:
|
||||
from = to;
|
||||
break;
|
||||
|
|
Loading…
Add table
Reference in a new issue