9 * Handlers for g_print() and g_printerr() which will output via
10 * WriteConsoleW when run under MS-Windows and the corresponding
11 * stream has not been re-directed. In all other cases, output
12 * via stdout and stderr respectively.
16 static HANDLE bl_console=0;
18 static void bl_print_handler_console(const char *string)
23 string2=g_utf8_to_utf16(string,-1,NULL,&len,NULL);
26 WriteConsoleW(bl_console,string2,len,&dummy,NULL);
32 static void bl_print_handler_stdout(const char *string)
37 static void bl_print_handler_stderr(const char *string)
42 void bl_set_print_handlers(void)
46 if (GetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE),&dummy))
48 bl_console=GetStdHandle(STD_OUTPUT_HANDLE);
49 g_set_print_handler(bl_print_handler_console);
53 g_set_print_handler(bl_print_handler_stdout);
55 if (GetConsoleMode(GetStdHandle(STD_ERROR_HANDLE),&dummy))
58 bl_console=GetStdHandle(STD_ERROR_HANDLE);
59 g_set_printerr_handler(bl_print_handler_console);
63 g_set_printerr_handler(bl_print_handler_stderr);