From 30c69ed93c47ef06a7a777bda2b02e6b7c25eedc Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Fri, 12 May 2017 04:18:06 +0200 Subject: Inkview: Fix encoding of console output on Windows To do this we have to "hack" g_print() as the glib people decided Windows consoles should be limited to 255 character code pages forevermore and g_print() converts all strings to the system's ANSI code page without exception. (see http://stackoverflow.com/q/43927373/2514664 for details) (bzr r15687.1.2) --- src/inkview.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/inkview.cpp') diff --git a/src/inkview.cpp b/src/inkview.cpp index abb12462a..cbbd4d6c3 100644 --- a/src/inkview.cpp +++ b/src/inkview.cpp @@ -248,8 +248,22 @@ private: Glib::OptionEntry _entry_args; }; + +#ifdef WIN32 +// minimal print handler (just prints the string to stdout) +void g_print_no_convert(const gchar *buf) +{ + fputs(buf, stdout); +} +#endif + int main (int argc, char **argv) { +#ifdef WIN32 + // Ugly hack to make g_print emit UTF-8 encoded characters. Otherwise glib will *always* + // perform character conversion to the system's ANSI code page making UTF-8 output impossible. + g_set_print_handler(g_print_no_convert); +#endif #ifdef ENABLE_NLS Inkscape::initialize_gettext(); #endif @@ -275,7 +289,7 @@ int main (int argc, char **argv) if(filenames.empty()) { - std::cout << opt.get_help(); + g_print(opt.get_help().c_str()); exit(EXIT_FAILURE); } -- cgit v1.2.3