ref: b1bc8b5c2b73a3b2cba83c12112644815e19c312
parent: 2dc7e311f43c41ecc412c237cbcb6293953c17e9
author: BurnZeZ <[email protected]>
date: Sun Oct 27 11:52:35 EDT 2013
libjson: handle unicode escapes
--- a/sys/src/libjson/json.c
+++ b/sys/src/libjson/json.c
@@ -52,6 +52,8 @@
{
Rune r;
char *t;
+ int i;
+ char c;
for(;;){
r = peekch(l);
@@ -116,6 +118,19 @@
break;
case 'r':
r = '\r';
+ break;
+ case 'u':
+ r = 0;
+ for(i = 0; i < 4; i++){
+ if(!isxdigit(peekch(l)))
+ break;
+
+ c = getch(l);
+ r *= 16;
+ if(c > '0' && c < '9') r += c - '0';
+ else if(c > 'a' && c < 'f') r += c - 'a' + 10;
+ else if(c > 'A' && c < 'F') r += c - 'A' + 10;
+ }
break;
case 't':
r = '\t';