std::ios_base:: getloc
From cppreference.net
C++
Input/output library
| I/O manipulators | ||||
| Print functions (C++23) | ||||
| C-style I/O | ||||
| Buffers | ||||
|
(C++23)
|
||||
|
(
C++98/26*
)
|
||||
|
(C++20)
|
||||
| Streams | ||||
| Abstractions | ||||
| File I/O | ||||
| String I/O | ||||
| Array I/O | ||||
|
(C++23)
|
||||
|
(C++23)
|
||||
|
(C++23)
|
||||
|
(
C++98/26*
)
|
||||
|
(
C++98/26*
)
|
||||
|
(
C++98/26*
)
|
||||
| Synchronized Output | ||||
|
(C++20)
|
||||
| Types | ||||
| Error category interface | ||||
|
(C++11)
|
||||
|
(C++11)
|
std::ios_base
| Member functions | ||||
| Formatting | ||||
| Locales | ||||
|
ios_base::getloc
|
||||
| Internal extensible array | ||||
| Miscellaneous | ||||
| Member classes | ||||
| Member types | ||||
|
std::
locale
getloc
(
)
const
;
|
||
返回与流关联的当前区域设置。
目录 |
参数
(无)
返回值
与流关联的区域设置对象。
示例
所示输出是使用 clang 编译器获得的。
运行此代码
#include <codecvt> #include <ctime> #include <iomanip> #include <iostream> 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.utf8"))); std::time_t t = std::time(nullptr); out << std::put_time(std::localtime(&t), L"%A %c") << '\n'; }
可能的输出:
木曜日 2023年10月05日 19時47分58秒
缺陷报告
以下行为变更缺陷报告被追溯应用于先前发布的C++标准。
| 缺陷报告 | 适用范围 | 发布时行为 | 正确行为 |
|---|---|---|---|
| LWG 47 | C++98 |
返回值被错误指定为
imbue()
的返回值
|
已修正 |
另请参阅
|
设置本地化环境
(公开成员函数) |