json - Valid UTF-8 string with Cyrillic symbols in C -


i try parse utf-8 json-message in c. pass following code parser:

char *text = "{\"mdl\":\"users\",\"fnc\":\"getuserslist\"}"; 

and works. if message has cyrillic characters, both of parsers string "not valid utf-8 string". example:

char *text = "{\"mdl\":\"пользователи\",\"fnc\":\"получитьсписокпользователей\"}"; 

i used jansson c parser , ccan json parcer c. in main function have following call of setlocale:

setlocale(lc_all, "ru_ru.utf8"); 

how can valid utf-8 string using cyrillic characters in it?

the relationship between source encoding (the encoding used encode text in c source) , target encoding (the encoding used encode run-time strings) not obvious. see this question more discussion this.

make sure source encoding utf-8, , compiler preserving this.

or, can manually encode strings utf-8, replacing non-ascii characters backslash-escaped utf-8 sequences more sure.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

javascript - Clean way to programmatically use CSS transitions from JS? -

android - send complex objects as post php java -