diff options
| author | Roman Lavrov <roman.lavrov@thebrowser.company> | 2026-03-25 16:24:21 -0400 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2026-06-09 14:06:00 -0700 |
| commit | 34d99cb07df7519c273aa352185df3a7e4a01bb9 (patch) | |
| tree | 34b4584eba1b9ac63db2de64d7d7c1340a1e8c21 /src/libs | |
| parent | 318f5300cf4244d6eb440b00278c062f1da56e91 (diff) | |
| download | wix-34d99cb07df7519c273aa352185df3a7e4a01bb9.tar.gz wix-34d99cb07df7519c273aa352185df3a7e4a01bb9.tar.bz2 wix-34d99cb07df7519c273aa352185df3a7e4a01bb9.zip | |
Skip SetConsoleCP when stdout is non-interactive.
Fixes wixtoolset/issues#9267
Diffstat (limited to 'src/libs')
| -rw-r--r-- | src/libs/dutil/WixToolset.DUtil/conutil.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/libs/dutil/WixToolset.DUtil/conutil.cpp b/src/libs/dutil/WixToolset.DUtil/conutil.cpp index 059af0e0..858128cd 100644 --- a/src/libs/dutil/WixToolset.DUtil/conutil.cpp +++ b/src/libs/dutil/WixToolset.DUtil/conutil.cpp | |||
| @@ -67,9 +67,14 @@ extern "C" HRESULT DAPI ConsoleInitialize() | |||
| 67 | vfConsoleOut = TRUE; | 67 | vfConsoleOut = TRUE; |
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | if (!::SetConsoleCP(CP_UTF8) || !::SetConsoleOutputCP(CP_UTF8)) | 70 | // Console codepage only applies to interactive sessions. SetConsoleCP may |
| 71 | // fail in console-less environments and the error path closes stdin/stdout. | ||
| 72 | if (vfStdOutInteractive) | ||
| 71 | { | 73 | { |
| 72 | ConExitWithLastError(hr, "failed to set console codepage to UTF-8"); | 74 | if (!::SetConsoleCP(CP_UTF8) || !::SetConsoleOutputCP(CP_UTF8)) |
| 75 | { | ||
| 76 | ConExitWithLastError(hr, "failed to set console codepage to UTF-8"); | ||
| 77 | } | ||
| 73 | } | 78 | } |
| 74 | 79 | ||
| 75 | LExit: | 80 | LExit: |
