2 * gcc -o utf8 utf8.c -I/home/y/include -L./.libs -ljson
9 #include "json_inttypes.h"
10 #include "json_object.h"
11 #include "json_tokener.h"
13 void print_hex( const char* s
)
17 while ((ch
= *iter
++) != 0)
29 const char *input
= "\"\\ud840\\udd26,\\ud840\\udd27,\\ud800\\udd26,\\ud800\\udd27\"";
30 const char *expected
= "\xF0\xA0\x84\xA6,\xF0\xA0\x84\xA7,\xF0\x90\x84\xA6,\xF0\x90\x84\xA7";
31 struct json_object
*parse_result
= json_tokener_parse((char*)input
);
32 const char *unjson
= json_object_get_string(parse_result
);
34 printf("input: %s\n", input
);
36 int strings_match
= !strcmp( expected
, unjson
);
40 printf("JSON parse result is correct: %s\n", unjson
);
43 printf("JSON parse result doesn't match expected string\n");
44 printf("expected string bytes: ");
46 printf("parsed string bytes: ");
51 json_object_put(parse_result
);