printing utf8 in glib
问题 Why utf8 symbols cannot be printed via glib functions? Source code: #include "glib.h" #include <stdio.h> int main() { g_print("марко\n"); fprintf(stdout, "марко\n"); } Build it like this: gcc main.c -o main $(pkg-config glib-2.0 --cflags --libs) You could see that glib can't print utf8 and fprintf can: [marko@marko-work utf8test]$ ./main ????? марко 回答1: fprint functions assume that every string you print with them is correctly encoded to match the current encoding of your terminal. g_print()