I try to parse an UTF-8 JSON-message in C. I pass the following code to the parser:
char *text = "{\"mdl\":\"users\",\"fnc\":\"getuserslist\"}";
and all works. But if message has a Cyrillic characters, both of my parsers say that string is "not valid UTF-8 string". Example:
char *text = "{\"mdl\":\"пользователи\",\"fnc\":\"получитьсписокпользователей\"}";
I used Jansson C parser and CCAN JSON parcer for C. In my main function I have the following call of setlocale:
setlocale(LC_ALL, "ru_RU.utf8");
How can I get the valid UTF-8 string using Cyrillic characters in it?
setlocale(LC_CTYPE, "")
to get the configured locale and thenassert
thatnl_langinfo(CODESET)
gives you the string"UTF-8"
or something similar.