std::locale getloc() const; |
Returns the current locale associated with the stream.
(none).
The locale object associated with the stream.
#include <iostream> #include <ctime> #include <iomanip> #include <codecvt> int main() { std::wbuffer_convert<std::codecvt_utf8<wchar_t>> conv(std::cout.rdbuf()); std::wostream out(&conv); out.imbue(std::locale(out.getloc(), new std::time_put_byname<wchar_t>("ja_JP"))); std::time_t t = std::time(nullptr); out << std::put_time(std::localtime(&t), L"%A %c") << '\n'; }
Possible output:
土曜日 2013年09月14日 11時31分15秒
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR | Applied to | Behavior as published | Correct behavior |
---|---|---|---|
LWG 47 | C++98 | the return value was misspecified as the return value of imbue() | corrected |
sets locale (public member function) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/w/cpp/io/ios_base/getloc