Date: Tue, 08 Dec 2020 10:27:54 +0000 From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 251674] libc++: std::wcout does not use global locale set via setlocale() Message-ID: <bug-251674-227-zaQtyLSqNg@https.bugs.freebsd.org/bugzilla/> In-Reply-To: <bug-251674-227@https.bugs.freebsd.org/bugzilla/> References: <bug-251674-227@https.bugs.freebsd.org/bugzilla/>
next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D251674 --- Comment #8 from Dimitry Andric <dim@FreeBSD.org> --- See e.g.: https://gcc.gnu.org/onlinedocs/libstdc++/manual/localization.html#locale.im= pl.c which says: > From Josuttis, p. 697-698, which says, that "there is only *one* > relation (of the C++ locale mechanism) to the C locale mechanism: the > global C locale is modified if a named C++ locale object is set as > the global locale" (emphasis Paolo), that is: > > std::locale::global(std::locale("")); > > affects the C functions as if the following call was made: > > std::setlocale(LC_ALL, ""); > > On the other hand, there is *no* vice versa, that is, calling > setlocale has *no* whatsoever on the C++ locale mechanism, in > particular on the working of locale(""), which constructs the locale > object from the environment of the running program, that is, in > practice, the set of LC_ALL, LANG, etc. variable of the shell. The above wording is also found in e.g. the C++11 standard, in [locale.statics]: > static locale global(const locale& loc); > > 1. Sets the global locale to its argument. > > 2. Effects: Causes future calls to the constructor locale() to return > a copy of the argument. If the argument has a name, does > > std::setlocale(LC_ALL, loc.name().c_str()); > > otherwise, the efect on the C locale, if any, is > implementation-defined. No library function other than > locale::global() shall afect the value returned by locale(). > [Note: See 22.6 for data race considerations when setlocale is > invoked.] > > 3. Returns: The previous value of locale(). --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-251674-227-zaQtyLSqNg>