Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(606)

Unified Diff: runtime/bin/platform_win.cc

Issue 2698813002: [dart:io][windows] Make unicode characters display correctly. (Closed)
Patch Set: Make tests pass Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/bin/platform_win.cc
diff --git a/runtime/bin/platform_win.cc b/runtime/bin/platform_win.cc
index 601d4d7b7635f0031e63b320c2fa3a7b5bdf7526..bbbd8b7841ed8eb61e19d8d9d8f196d0d4b052e7 100644
--- a/runtime/bin/platform_win.cc
+++ b/runtime/bin/platform_win.cc
@@ -27,7 +27,12 @@ char* Platform::resolved_executable_name_ = NULL;
int Platform::script_index_ = 1;
char** Platform::argv_ = NULL;
+static int old_output_cp = -1;
+
bool Platform::Initialize() {
+ ASSERT(old_output_cp == -1);
+ old_output_cp = GetConsoleOutputCP();
+ SetConsoleOutputCP(CP_UTF8);
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
return true;
}
@@ -124,6 +129,11 @@ const char* Platform::ResolveExecutablePath() {
void Platform::Exit(int exit_code) {
// TODO(zra): Remove once VM shuts down cleanly.
::dart::private_flag_windows_run_tls_destructors = false;
+ // Restore the console's output code page
+ if (old_output_cp != -1) {
+ SetConsoleOutputCP(old_output_cp);
Florian Schneider 2017/02/21 20:34:50 Can there be multiple threads calling Platform::Ex
zra 2017/02/21 21:26:46 Yes. This can happen if multiple isolates call Pla
+ old_output_cp = -1;
+ }
// On Windows we use ExitProcess so that threads can't clobber the exit_code.
// See: https://code.google.com/p/nativeclient/issues/detail?id=2870
::ExitProcess(exit_code);

Powered by Google App Engine
This is Rietveld 408576698