Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

std::wcout locale defaults to C #47413

Open Quuxplusone opened 3 years ago

Quuxplusone commented 3 years ago
Bugzilla Link PR48444
Status NEW
Importance P enhancement
Reported by Yuri (yuri@tsoft.com)
Reported on 2020-12-08 09:33:12 -0800
Last modified on 2020-12-08 09:54:52 -0800
Version 11.0
Hardware PC FreeBSD
CC llvm-bugs@lists.llvm.org, mclow.lists@gmail.com
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
This
> std::cout << "std::wcout's locale=" << std::wcout.getloc().name() <<
std::endl;
prints "C" by default, despite user's locale being en_US.UTF-8

Is the choice of "C" based on some requirement stated in standards?

As it is now, users always need to call "std::wcout.imbue(std::locale(""));" in
order to make std::wcout usable with non-ASCII characters.

It would seem that std::wcout's default of "" or same as user's locale would
have been more practical.

Do users really always need to call "std::wcout.imbue(std::locale(""));" before
std::wcout can become usable?

OS: FreeBSD
clang-10

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=251674
Quuxplusone commented 3 years ago
Quick check - on Ubuntu 18.14, using gCC 7.5.0 and libstdc++, your line prints:

std::wcout's locale=C

and
$ echo $LANG
en_US.UTF-8