(说明:彩色部分为(类型、结构、宏和函数的)名称,其中红色的为较常用的,
绿色为不太常用的)
常用的宽字符函数:
#include <wchar.h>
size_t wcslen(const wchar_t *s);
int wprintf(const wchar_t * format, ...);
int wscanf(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, ...);
long int wcstol(const wchar_t * nptr, wchar_t ** endptr, int base);
float wcstof(const wchar_t * nptr, wchar_t ** endptr);
double wcstod(const wchar_t * nptr, wchar_t ** endptr);
#include <stdlib.h>
errno_t _itow_s( int value, wchar_t *buffer, size_t sizeInCharacters, int radix );
errno_t _ultow_s( unsigned long value, wchar_t *str, size_t sizeOfstr, int radix );
B.23 扩展多字节与宽字符工具<wchar.h>
Extended multibyte and wide-character utilities <wchar.h>
类型:
wchar_t(宽字符类型,VC中定义为2B的unsigned short)
wint_t(可保存扩展字符值的一种整数类型,VC中定义为4B的int)
size_t(sizeof返回的整数类型,VC中定义为4B的unsigned int)
mbstate_t(保存转换状态信息的类型,VC中定义为4B的int)
结构:
struct tm(日期时间结构)
struct tmx(日期时间扩展结构)
宏:
NULL(空指针,VC中定义为((void *)0))
WCHAR_MAX(宽字符的最大值,VC中定义为0xFFFF[65535])
WCHAR_MIN(宽字符的最小值,VC中定义为0)
WEOF(宽字符输入的文件结尾,VC中定义为(wint_t)(0xFFFF)[65535])
函数:
I/O函数:
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(FILE * stream, 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(void);
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);
wchar_t *wcsncpy(wchar_t * s1, const wchar_t * s2, size_t n);
wchar_t *wcscat(wchar_t * s1, const wchar_t * s2);
wchar_t *wcsncat(wchar_t * s1, const wchar_t * s2, size_t n);
int wcscmp(const wchar_t *s1, const wchar_t *s2);
int wcscoll(const wchar_t *s1, const wchar_t *s2);
int wcsncmp(const wchar_t *s1, const wchar_t *s2, size_t n);
size_t wcsxfrm(wchar_t * s1, const wchar_t * s2, size_t n);
wchar_t *wcschr(const wchar_t *s, wchar_t c);
size_t wcscspn(const wchar_t *s1, const wchar_t *s2);
size_t wcslen(const wchar_t *s);
wchar_t *wcspbrk(const wchar_t *s1, const wchar_t *s2);
wchar_t *wcsrchr(const wchar_t *s, wchar_t c);
size_t wcsspn(const wchar_t *s1, const wchar_t *s2);
wchar_t *wcsstr(const wchar_t *s1, const wchar_t *s2);
wchar_t *wcstok(wchar_t * s1, const wchar_t * s2, wchar_t ** ptr);
wchar_t *wmemchr(const wchar_t *s, wchar_t c, size_t n);
int wmemcmp(wchar_t * s1, const wchar_t * s2, size_t n);
wchar_t *wmemcpy(wchar_t * s1, const wchar_t * s2, size_t n);
wchar_t *wmemmove(wchar_t *s1, const wchar_t *s2, size_t n);
wchar_t *wmemset(wchar_t *s, wchar_t c, size_t n);
size_t wcsftime(wchar_t *s, size_t maxsize, const wchar_t *format, const struct tm *timeptr);
size_t wcsfxtime(wchar_t *s, size_t maxsize, const wchar_t *format, const struct tmx *timeptr);
转换函数:
wint_t btowc(int c);
int wctob(wint_t c);
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);
B.24 宽字符分类和映射工具<wctype.h>
Wide-character classification and mapping utilities <wctype.h>
类型:
wint_t(可保存扩展字符值的一种整数类型,VC中定义为2B的unsigned short)
wctrans_t(表示特定字符映射的一种标量类型,VC中定义为wchar_t)
wctype_t(表示字符分类的一种标量类型,VC中也定义为2B的unsigned short)
宏:
WEOF(宽字符输入的文件结尾,VC中定义为(wint_t)(0xFFFF)[65535])
函数:
分类函数:
int iswalnum(wint_t wc);
int iswalpha(wint_t wc);
int iswcntrl(wint_t wc);
int iswdigit(wint_t wc);
int iswgraph(wint_t wc);
int iswlower(wint_t wc);
int iswprint(wint_t wc);
int iswpunct(wint_t wc);
int iswspace(wint_t wc);
int iswupper(wint_t wc);
int iswxdigit(wint_t wc);
可扩展分类函数:
int iswctype(wint_t wc, wctype_t desc);
wctype_t wctype(const char *property);
转换函数:
wint_t towlower(wint_t wc);
wint_t towupper(wint_t wc);
wint_t towctrans(wint_t wc, wctrans_t desc);
wctrans_t wctrans(const char *property);