summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/helper/gettext.cpp23
-rw-r--r--src/winconsole.cpp8
2 files changed, 20 insertions, 11 deletions
diff --git a/src/helper/gettext.cpp b/src/helper/gettext.cpp
index 0972d4e19..91dfdbcb8 100644
--- a/src/helper/gettext.cpp
+++ b/src/helper/gettext.cpp
@@ -49,9 +49,8 @@ void initialize_gettext() {
bindtextdomain(GETTEXT_PACKAGE, localepath);
g_free(shortdatadir);
g_free(localepath);
-
- g_free(datadir);
+ g_free(datadir);
#else
# ifdef ENABLE_BINRELOC
bindtextdomain(GETTEXT_PACKAGE, BR_LOCALEDIR(""));
@@ -79,21 +78,23 @@ void bind_textdomain_codeset_utf8() {
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
}
-/** set gettext codeset to codeset of the console
+/** set gettext codeset to codeset of the system console
* - on *nix this is typically the current locale,
- * - on Windows it has to be determined using GetConsoleOutputCP() */
+ * - on Windows we don't care and simply use UTF8
+ * any conversion would need to happen in our console wrappers (see winconsole.cpp) anyway
+ * as we have no easy way of determining console encoding from inkscape/inkview.exe process;
+ * for now do something even easier - switch console encoding to UTF8 and be done with it!
+ * this also works nicely on MSYS consoles where UTF8 encoding is used by default, too */
void bind_textdomain_codeset_console() {
+#ifdef WIN32
+ bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
+#else
std::string charset;
Glib::get_charset(charset);
-
- // TODO: does not work properly as we spawn a child process on Windows
- // (inkscape.exe is not a console application and can never print directly to console)
- //unsigned int test = GetConsoleOutputCP();
- //g_message("CP%u", test);
-
bind_textdomain_codeset(GETTEXT_PACKAGE, charset.c_str());
+#endif
}
-
+
}
diff --git a/src/winconsole.cpp b/src/winconsole.cpp
index 085fb441c..f91b19c5c 100644
--- a/src/winconsole.cpp
+++ b/src/winconsole.cpp
@@ -100,6 +100,11 @@ int main()
// it guarantees perfect behavior w.r.t. quoting
WCHAR *cmd = GetCommandLineW();
+ // temporarily switch console encoding to UTF8 while the spwaned process runs
+ // as everything else is a mess and it seems to work just fine
+ const unsigned int initial_cp = GetConsoleOutputCP();
+ SetConsoleOutputCP(CP_UTF8);
+
// set up the pipes and handles
stdin.echo_read = GetStdHandle(STD_INPUT_HANDLE);
stdout.echo_write = GetStdHandle(STD_OUTPUT_HANDLE);
@@ -148,6 +153,9 @@ int main()
// wait until the standard output thread terminates
WaitForSingleObject(stdout_thread, INFINITE);
+ // switch back to initial console encoding
+ SetConsoleOutputCP(initial_cp);
+
return 0;
}