Found a bug!
Closed this issue · 13 comments
STREQ(json_object_get_string(root_object, "utf string"), "lorem ipsum中华人2民共和国")- FAIL
STREQ(json_object_get_string(root_object, "utf-8 string"), "**あいうえお")- FAIL
Did you just change code in tests.c without changing files used for those tests?
Please provide a way of reproducing this "bug".
I just changed test.c
TEST(json_object_set_string(obj, "utf string", "lorem ipsum中华人2民共和国") == JSONSuccess);
TEST(json_object_set_string(obj, "utf-8 string", "あい**うえお") == JSONSuccess);
You need to change tests/test_2.txt
and tests/test_2_comments.txt
as well.
Thank You
Is Work now!
But json_object_set_string not work in VS2019 when used "中华人民共和国" or any chinese word。
code:
JSON_Value *root_value = json_value_init_object();
JSON_Object *root_object = json_value_get_object(root_value);
char *serialized_string = NULL;
json_object_set_string(root_object, "name", "中华人民共和国");
json_object_set_number(root_object, "age", 25);
serialized_string = json_serialize_to_string(root_value);
printf(serialized_string);
json_free_serialized_string(serialized_string);
json_value_free(root_value);
Is your source file encoded using utf8?
is Worked from cJson+VS2019
char* name = "中华人2民共和国";
cJSON* objjson = cJSON_CreateObject();
cJSON_AddNumberToObject(objjson, "code", 120);
cJSON_AddStringToObject(objjson, "data", name);
char* serialized_string = cJSON_Print(objjson);
printf(serialized_string);
No,encoded used gb2312
cpp file encoded gb2312
Please change it to utf-8, it should help.
Thank You! I'll give it a try
if I receved chinese word from network,I need change to UTF-8?
gb2312 is a subset of unicode so it should work.
Does your example work after changing
json_object_set_string(root_object, "name", "中华人民共和国");
to
json_object_set_string(root_object, "name", u8"中华人民共和国");
?
I'm closing this issue since it seems to be a problem in your setup.