mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-10-03 12:19:20 +02:00
Convert to the console charset only if the stream outputs to the console
This commit is contained in:
@@ -77,15 +77,16 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef G_OS_WIN32
|
#ifdef G_OS_WIN32
|
||||||
|
#include "gwin32.h"
|
||||||
|
#include "gwin32private.h"
|
||||||
|
|
||||||
#include <process.h> /* For getpid() */
|
#include <process.h> /* For getpid() */
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
# include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
#ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING
|
#ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING
|
||||||
#define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004
|
#define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "gwin32.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -3470,12 +3471,30 @@ static void
|
|||||||
print_string (FILE *stream,
|
print_string (FILE *stream,
|
||||||
const gchar *string)
|
const gchar *string)
|
||||||
{
|
{
|
||||||
const gchar *charset;
|
const gchar *charset = NULL;
|
||||||
|
bool print_utf8;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (g_get_console_charset (&charset))
|
#ifdef _WIN32
|
||||||
|
int fd;
|
||||||
|
HANDLE handle;
|
||||||
|
|
||||||
|
fd = _fileno (stream);
|
||||||
|
if (fd < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
handle = (HANDLE) _get_osfstream (fd);
|
||||||
|
|
||||||
|
if (g_win32_handle_is_console_output (handle))
|
||||||
|
print_utf8 = g_get_console_charset (&charset);
|
||||||
|
else
|
||||||
|
print_utf8 = true;
|
||||||
|
#else
|
||||||
|
print_utf8 = g_get_charset (&charset);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (print_utf8)
|
||||||
{
|
{
|
||||||
/* charset is UTF-8 already */
|
|
||||||
ret = fputs (string, stream);
|
ret = fputs (string, stream);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Reference in New Issue
Block a user