File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Source/UnrealEnginePython/Private Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -34,9 +34,14 @@ const char *ue4_module_options = "linux_global_symbols";
3434#include " Runtime/Core/Public/Misc/CommandLine.h"
3535#include " Runtime/Core/Public/Misc/ConfigCacheIni.h"
3636#include " Runtime/Core/Public/GenericPlatform/GenericPlatformFile.h"
37+ #include " Runtime/Core/Public/GenericPlatform/GenericPlatformMisc.h"
3738
3839#include " Runtime/Core/Public/HAL/FileManagerGeneric.h"
3940
41+ #if PLATFORM_WINDOWS
42+ #include < fcntl.h>
43+ #endif
44+
4045#if PLATFORM_ANDROID
4146#include " Android/AndroidJNI.h"
4247#include " Android/AndroidApplication.h"
@@ -451,6 +456,22 @@ void FUnrealEnginePythonModule::StartupModule()
451456
452457 Py_Initialize ();
453458
459+ #if PLATFORM_WINDOWS
460+ // Restore stdio state after Py_Initialize set it to O_BINARY, otherwise
461+ // everything that the engine will output is going to be encoded in UTF-16.
462+ // The behaviour is described here: https://bugs.python.org/issue16587
463+ _setmode (fileno (stdin), O_TEXT);
464+ _setmode (fileno (stdout), O_TEXT);
465+ _setmode (fileno (stderr), O_TEXT);
466+
467+ // Also restore the user-requested UTF-8 flag if relevant (behaviour copied
468+ // from LaunchEngineLoop.cpp).
469+ if (FParse::Param (FCommandLine::Get (), TEXT (" UTF8Output" )))
470+ {
471+ FPlatformMisc::SetUTF8Output ();
472+ }
473+ #endif
474+
454475 PyEval_InitThreads ();
455476
456477#if WITH_EDITOR
You can’t perform that action at this time.
0 commit comments