zero-terminate utf8 strings in ent

master
leitner 7 years ago
parent ed67042965
commit 112ccf19e7

@ -197,6 +197,7 @@ int main() {
#endif #endif
if (*s==']') break; if (*s==']') break;
} while (*s==','); } while (*s==',');
(*cur)->utf8[ul]=0;
#if 0 #if 0
puts("\" },"); puts("\" },");
#endif #endif

2
t.c

@ -132,7 +132,7 @@ int main(int argc,char* argv[]) {
assert(scan_jsonescape("foo\\u000abar\\\\",buf,&l)==14 && l==8 && byte_equal(buf,8,"foo\nbar\\")); assert(scan_jsonescape("foo\\u000abar\\\\",buf,&l)==14 && l==8 && byte_equal(buf,8,"foo\nbar\\"));
memset(buf,0,sizeof(buf)); memset(buf,0,sizeof(buf));
/* example from the json spec: G clef U+1D11E encoded using UTF-16 surrogates*/ /* example from the json spec: G clef U+1D11E encoded using UTF-16 surrogates*/
assert(scan_jsonescape("\\uD834\\uDD1Exyz",buf,&l)==15 && l==7 && byte_equal(buf,7,"\xf4\x8d\x84\x9exyz")); assert(scan_jsonescape("\\uD834\\uDD1Exyz",buf,&l)==15 && l==7 && byte_equal(buf,7,"\xf0\x9d\x84\x9exyz"));
/* /*
1D11E -> 0001 1101 0001 0001 1110 1D11E -> 0001 1101 0001 0001 1110

Loading…
Cancel
Save