Skip to content

Commit 8e8b9a1

Browse files
authored
Merge pull request #40929 from compnerd/5.5.3-unicode
[5.5] stdlib: change the console to UTF-8 on start
2 parents 6ad300d + 83ce537 commit 8e8b9a1

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

stdlib/public/stubs/LibcShims.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@
3131

3232
#include "../SwiftShims/LibcShims.h"
3333

34+
#if defined(_WIN32)
35+
static void __attribute__((__constructor__))
36+
_swift_stdlib_configure_console_mode(void) {
37+
static UINT uiPrevConsoleCP = GetConsoleOutputCP();
38+
atexit([]() { SetConsoleOutputCP(uiPrevConsoleCP); });
39+
SetConsoleOutputCP(CP_UTF8);
40+
}
41+
#endif
42+
3443
SWIFT_RUNTIME_STDLIB_INTERNAL
3544
int _swift_stdlib_putchar_unlocked(int c) {
3645
#if defined(_WIN32)
@@ -42,9 +51,9 @@ int _swift_stdlib_putchar_unlocked(int c) {
4251

4352
SWIFT_RUNTIME_STDLIB_INTERNAL
4453
__swift_size_t _swift_stdlib_fwrite_stdout(const void *ptr,
45-
__swift_size_t size,
46-
__swift_size_t nitems) {
47-
return fwrite(ptr, size, nitems, stdout);
54+
__swift_size_t size,
55+
__swift_size_t nitems) {
56+
return fwrite(ptr, size, nitems, stdout);
4857
}
4958

5059
SWIFT_RUNTIME_STDLIB_SPI

test/Concurrency/Runtime/async_taskgroup_asynciterator_semantics.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
// REQUIRES: concurrency_runtime
55
// UNSUPPORTED: back_deployment_runtime
66
// UNSUPPORTED: linux
7-
// XFAIL: windows
87

98
struct Boom: Error {}
109

test/Concurrency/Runtime/async_taskgroup_is_asyncsequence.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// UNSUPPORTED: back_deployment_runtime
99

1010
// UNSUPPORTED: linux
11-
// XFAIL: windows
1211

1312
@available(SwiftStdlib 5.5, *)
1413
func test_taskGroup_is_asyncSequence() async {

test/Concurrency/Runtime/async_taskgroup_throw_rethrow.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
// REQUIRES: concurrency_runtime
88
// UNSUPPORTED: back_deployment_runtime
99

10-
// XFAIL: OS=windows-msvc
11-
1210
struct Boom: Error {}
1311
struct IgnoredBoom: Error {}
1412

0 commit comments

Comments
 (0)