It seems there is a problem with the Unicode implementation.
I write :
JSONNODE * card = json_new(JSON_ARRAY);
JSONNODE *c = json_new(JSON_ARRAY);
json_push_back(c, json_new_a(_T("name"), _T("Entrée Audio Intégrée 1")));
json_push_back(c, json_new_i(NULL, 0));
json_char *jc = json_write(card);
and the result is "" without "é"
The unicode flag is set.
Do you know where is the problem ?
I think the problem comes from the json_write function.
When I use iterator, the "é" is in the string, but not when I use json_write.
I hop it will help you.
Huh, stupid me, when I was doing the move to 6.0 I forgot to uncomment the part that added Unicode encoding to the write. I've added this to my unit test suite and once it passes I will release a new version. Probably tomorrow, the unit test suite takes about 12 hours to run.
Fixed in version 6.1.2. Thank you for reporting this bug to me, which each problem I fix, the better libjson becomes :)
I use the 6.1.2 version and I get
using the same code. (and only unicode activated, all other option by default).
I think there is yet a little problem, no?
is 00E9 not the correct value? Unicode characters are not put into json as-is. The JSON standard says that they must be escaped using the \u prefix.
cout << (int)_T('é') << endl;
cout << 0x00E9 << endl;
ok, I thought Unicode characters was put as-is.
Thanks for your answer.
I just want to tell that this lib is very very nice and you answer quickly. Thanks a lot.
I'm glad you like libjson. If you have any other problems, please post, I usually respond within a day or two.
Just FYI, there is now a compile option: JSON_ESCAPE_WRITES. You can turn it off and unicode characters will appear as thoy are, but obviously this breaks the JSON standard.
Log in to post a comment.