diff options
| author | Eduard Braun <eduard.braun2@gmx.de> | 2017-05-12 02:18:06 +0000 |
|---|---|---|
| committer | Eduard Braun <eduard.braun2@gmx.de> | 2017-05-12 02:18:06 +0000 |
| commit | 30c69ed93c47ef06a7a777bda2b02e6b7c25eedc (patch) | |
| tree | 0a35e00a74b435655fa5df9afba5f79c6291ec31 /src/inkview.cpp | |
| parent | Inkview: Fix gettext localization (diff) | |
| download | inkscape-30c69ed93c47ef06a7a777bda2b02e6b7c25eedc.tar.gz inkscape-30c69ed93c47ef06a7a777bda2b02e6b7c25eedc.zip | |
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)
Diffstat (limited to 'src/inkview.cpp')
| -rw-r--r-- | src/inkview.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
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); } |
