标准库头文件 <cwchar>
来自 cppreference.cn
此头文件最初是 C 标准库中的 <wchar.h>。
此头文件是空终止 宽 和 多字节 字符串库的一部分。它还提供了一些 C 风格的 I/O 函数和从 C 风格日期 的转换。
目录 |
[编辑] 宏
实现定义的空指针常量 (宏常量) | |
WEOF |
类型为 std::wint_t 的非字符值,用于指示错误(宏常量) |
WCHAR_MIN |
wchar_t 的最小有效值 (宏常量) |
WCHAR_MAX |
wchar_t 的最大有效值 (宏常量) |
[编辑] 类型
迭代多字节字符串所需的转换状态信息 (类) | |
由 sizeof 运算符返回的无符号整型 (typedef) | |
wint_t
|
可容纳任何有效宽字符和至少一个额外值的整型 |
日历时间类型 (类) |
[编辑] 函数
字符串操作 | |
将一个宽字符串复制到另一个宽字符串 (函数) | |
将一定数量的宽字符从一个字符串复制到另一个字符串 (函数) | |
将一个宽字符串的副本追加到另一个宽字符串 (函数) | |
将一定数量的宽字符从一个宽字符串附加到另一个宽字符串 (函数) | |
转换宽字符串,使 wcscmp 产生与 wcscoll 相同的结果(函数) | |
字符串检查 | |
返回宽字符串的长度 (函数) | |
比较两个宽字符串 (函数) | |
比较两个宽字符串中的一定数量的字符 (函数) | |
根据当前语言环境比较两个宽字符串 (函数) | |
在宽字符串中查找宽字符的首次出现 (函数) | |
在宽字符串中查找宽字符的最后一次出现 (函数) | |
返回由另一个字节字符串中找到的字符组成的最大初始段的长度 仅包含在另一个宽字符串中找到的宽字符 (函数) | |
返回由另一个字节字符串中找到的字符组成的最大初始段的长度 仅当另一个宽字符串中未找到宽字符时 (函数) | |
在另一个宽字符串中查找一个宽字符串中任意宽字符的首次出现位置 (函数) | |
在一个宽字符串中查找另一个宽字符串的首次出现 (函数) | |
在宽字符串中查找下一个标记 (函数) | |
宽字符数组操作 | |
在两个不重叠的数组之间复制一定数量的宽字符 (函数) | |
在两个可能重叠的数组之间复制一定数量的宽字符 (函数) | |
比较两个数组中一定数量的宽字符 (函数) | |
在宽字符数组中查找宽字符的首次出现 (函数) | |
将给定宽字符复制到宽字符数组中的每个位置 (函数) | |
多字节/宽字符转换 | |
检查 std::mbstate_t 对象是否表示初始移位状态 (函数) | |
如果可能,将单字节窄字符加宽为宽字符 (函数) | |
如果可能,将宽字符缩小为单字节窄字符 (函数) | |
返回下一个多字节字符的字节数,给定状态 (函数) | |
将下一个多字节字符转换为宽字符,给定状态 (函数) | |
将宽字符转换为其多字节表示,给定状态 (函数) | |
将窄多字节字符字符串转换为宽字符串,给定状态 (函数) | |
将宽字符串转换为窄多字节字符字符串,给定状态 (函数) | |
输入/输出 | |
从文件流中获取一个宽字符 (函数) | |
从文件流中获取一个宽字符串 (函数) | |
向文件流写入一个宽字符 (函数) | |
向文件流写入一个宽字符串 (函数) | |
从 stdin 读取宽字符 (函数) | |
向 stdout 写入宽字符 (函数) | |
将一个宽字符放回文件流中 (函数) | |
在宽字符 I/O 和窄字符 I/O 之间切换文件流 (函数) | |
从 stdin、文件流或缓冲区读取格式化的宽字符输入 (函数) | |
(C++11)(C++11)(C++11) |
从 stdin、文件流读取格式化的宽字符输入 或使用可变参数列表的缓冲区 (函数) |
向 stdout、文件流或缓冲区打印格式化的宽字符输出 (函数) | |
向 stdout、文件流打印格式化的宽字符输出 或使用可变参数列表的缓冲区 (函数) | |
字符串转换 | |
将 std::tm 对象转换为自定义宽字符串文本表示 (函数) | |
将宽字符串转换为整数值 (函数) | |
将宽字符串转换为无符号整数值 (函数) | |
将宽字符串转换为浮点值 (函数) |
[编辑] 注意
- NULL 也定义在以下头文件中
- std::size_t 也定义在以下头文件中
-
std::wint_t
也定义在以下头文件中 - std::tm 也定义在以下头文件中
[编辑] 概要
namespace std { using size_t = /* see description */; // freestanding using mbstate_t = /* see description */; // freestanding using wint_t = /* see description */; // freestanding struct tm; int fwprintf(FILE* stream, const wchar_t* format, ...); int fwscanf(FILE* stream, const wchar_t* format, ...); int swprintf(wchar_t* s, size_t n, const wchar_t* format, ...); int swscanf(const wchar_t* s, const wchar_t* format, ...); int vfwprintf(FILE* stream, const wchar_t* format, va_list arg); int vfwscanf(FILE* stream, const wchar_t* format, va_list arg); int vswprintf(wchar_t* s, size_t n, const wchar_t* format, va_list arg); int vswscanf(const wchar_t* s, const wchar_t* format, va_list arg); int vwprintf(const wchar_t* format, va_list arg); int vwscanf(const wchar_t* format, va_list arg); int wprintf(const wchar_t* format, ...); int wscanf(const wchar_t* format, ...); wint_t fgetwc(FILE* stream); wchar_t* fgetws(wchar_t* s, int n, FILE* stream); wint_t fputwc(wchar_t c, FILE* stream); int fputws(const wchar_t* s, FILE* stream); int fwide(FILE* stream, int mode); wint_t getwc(FILE* stream); wint_t getwchar(); wint_t putwc(wchar_t c, FILE* stream); wint_t putwchar(wchar_t c); wint_t ungetwc(wint_t c, FILE* stream); double wcstod(const wchar_t* nptr, wchar_t** endptr); float wcstof(const wchar_t* nptr, wchar_t** endptr); long double wcstold(const wchar_t* nptr, wchar_t** endptr); long int wcstol(const wchar_t* nptr, wchar_t** endptr, int base); long long int wcstoll(const wchar_t* nptr, wchar_t** endptr, int base); unsigned long int wcstoul(const wchar_t* nptr, wchar_t** endptr, int base); unsigned long long int wcstoull(const wchar_t* nptr, wchar_t** endptr, int base); wchar_t* wcscpy(wchar_t* s1, const wchar_t* s2); // freestanding wchar_t* wcsncpy(wchar_t* s1, const wchar_t* s2, size_t n); // freestanding wchar_t* wmemcpy(wchar_t* s1, const wchar_t* s2, size_t n); // freestanding wchar_t* wmemmove(wchar_t* s1, const wchar_t* s2, size_t n); // freestanding wchar_t* wcscat(wchar_t* s1, const wchar_t* s2); // freestanding wchar_t* wcsncat(wchar_t* s1, const wchar_t* s2, size_t n); // freestanding int wcscmp(const wchar_t* s1, const wchar_t* s2); // freestanding int wcscoll(const wchar_t* s1, const wchar_t* s2); int wcsncmp(const wchar_t* s1, const wchar_t* s2, size_t n); // freestanding size_t wcsxfrm(wchar_t* s1, const wchar_t* s2, size_t n); int wmemcmp(const wchar_t* s1, const wchar_t* s2, size_t n); // freestanding const wchar_t* wcschr(const wchar_t* s, wchar_t c); // freestanding wchar_t* wcschr(wchar_t* s, wchar_t c); // freestanding size_t wcscspn(const wchar_t* s1, const wchar_t* s2); // freestanding const wchar_t* wcspbrk(const wchar_t* s1, const wchar_t* s2); // freestanding wchar_t* wcspbrk(wchar_t* s1, const wchar_t* s2); // freestanding const wchar_t* wcsrchr(const wchar_t* s, wchar_t c); // freestanding wchar_t* wcsrchr(wchar_t* s, wchar_t c); // freestanding size_t wcsspn(const wchar_t* s1, const wchar_t* s2); // freestanding const wchar_t* wcsstr(const wchar_t* s1, const wchar_t* s2); // freestanding wchar_t* wcsstr(wchar_t* s1, const wchar_t* s2); // freestanding wchar_t* wcstok(wchar_t* s1, const wchar_t* s2, wchar_t** ptr); // freestanding const wchar_t* wmemchr(const wchar_t* s, wchar_t c, size_t n); // freestanding wchar_t* wmemchr(wchar_t* s, wchar_t c, size_t n); // freestanding size_t wcslen(const wchar_t* s); // freestanding wchar_t* wmemset(wchar_t* s, wchar_t c, size_t n); // freestanding size_t wcsftime(wchar_t* s, size_t maxsize, const wchar_t* format, const tm* timeptr); wint_t btowc(int c); int wctob(wint_t c); // multibyte / wide string and character conversion functions int mbsinit(const mbstate_t* ps); size_t mbrlen(const char* s, size_t n, mbstate_t* ps); size_t mbrtowc(wchar_t* pwc, const char* s, size_t n, mbstate_t* ps); size_t wcrtomb(char* s, wchar_t wc, mbstate_t* ps); size_t mbsrtowcs(wchar_t* dst, const char** src, size_t len, mbstate_t* ps); size_t wcsrtombs(char* dst, const wchar_t** src, size_t len, mbstate_t* ps); } #define NULL /* see description */ // freestanding #define WCHAR_MAX /* see description */ // freestanding #define WCHAR_MIN /* see description */ // freestanding #define WEOF /* see description */ // freestanding
[编辑] 缺陷报告
下列更改行为的缺陷报告追溯地应用于以前出版的 C++ 标准。
缺陷报告 | 应用于 | 发布时的行为 | 正确的行为 |
---|---|---|---|
LWG 345 | C++98 | std::tm 未在 <cwchar> 中提供 |
已提供 |