Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
longnguyen2004 mannequin opened this issue Aug 25, 2020 · 2 comments
Closed

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

longnguyen2004 mannequin opened this issue Aug 25, 2020 · 2 comments
Labels
bugzilla Issues migrated from bugzilla libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

Comments

@longnguyen2004
Copy link
Mannequin

longnguyen2004 mannequin commented Aug 25, 2020

Bugzilla Link 47302
Version 10.0
OS Windows NT
CC @mclow

Extended Description

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

@longnguyen2004
Copy link
Mannequin Author

longnguyen2004 mannequin commented Aug 25, 2020

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;
}

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
@mstorsjo
Copy link
Member

I've posted an initial patch that tries to fix this issue at https://reviews.llvm.org/D146398.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

No branches or pull requests

1 participant