printing utf8 in glib

后端 未结 4 1421
北荒
北荒 2021-02-14 18:43

Why utf8 symbols cannot be printed via glib functions?

Source code:

#include \"glib.h\"
#include 

int main() {
    g_print(\"марко\\n\");         


        
4条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-14 19:21

    You need to initialize the locale's encoding by calling setlocale at your program's start.

    setlocale(LC_CTYPE, "")
    

    This is normally carried out for you if you use some initialization function like gtk_init(..) or similar.

提交回复
热议问题