Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

mingw-w64: std::wcout after _setmode(_fileno(stdout), _O_WTEXT) doesn't work #46271

Open Quuxplusone opened 4 years ago

Quuxplusone commented 4 years ago
Bugzilla Link PR47302
Status NEW
Importance P normal
Reported by Long Nguyen (nguyen.long.908132@gmail.com)
Reported on 2020-08-24 22:14:49 -0700
Last modified on 2020-08-24 22:24:21 -0700
Version 10.0
Hardware PC Windows NT
CC llvm-bugs@lists.llvm.org, mclow.lists@gmail.com
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
Take this code snippet:
#include <iostream>
#include <io.h>
#include <fcntl.h>

int wmain(int argc, const wchar_t* argv[])
{
    _setmode(_fileno(stdout), _O_WTEXT);
    std::wcout << L"Thử nghiệm\n";
    return 0;
}

On MS STL, this correctly outputs the string, but on libc++ it outputs nothing.

Additional notes:
Add -municode when compiling with clang, and add /utf-8 when compiling with MSVC
Quuxplusone commented 4 years ago
In contrast, the following equivalent C code works on both:
#include <stdio.h>
#include <io.h>
#include <fcntl.h>

int wmain(int argc, const wchar_t* argv[])
{
    _setmode(_fileno(stdout), _O_WTEXT);
    _putws(L"Thử nghiệm\n");
    return 0;
}