Namespaces
Variants
Actions

Standard library header <cwchar>

From cppreference.com
< cpp‎ | header
 
 
Standard library headers
 

This header was originally in the C standard library as <wchar.h>.

This header is part of the null-terminated wide and multibyte strings libraries. It also provides some C-style I/O functions and conversion from C-style Date.

Contents

[edit]Macros

implementation-defined null pointer constant
(macro constant)[edit]
WEOF
a non-character value of type std::wint_t used to indicate errors
(macro constant)
WCHAR_MIN
the smallest valid value of wchar_t
(macro constant)
WCHAR_MAX
the largest valid value of wchar_t
(macro constant)

[edit]Types

conversion state information necessary to iterate multibyte character strings
(class)[edit]
unsigned integer type returned by the sizeof operator
(typedef)[edit]
wint_t integer type that can hold any valid wide character and at least one more value
calendar time type
(class)[edit]

[edit]Functions

String manipulation
copies one wide string to another
(function)[edit]
copies a certain amount of wide characters from one string to another
(function)[edit]
appends a copy of one wide string to another
(function)[edit]
appends a certain amount of wide characters from one wide string to another
(function)[edit]
transform a wide string so that wcscmp would produce the same result as wcscoll
(function)[edit]
String examination
returns the length of a wide string
(function)[edit]
compares two wide strings
(function)[edit]
compares a certain amount of characters from two wide strings
(function)[edit]
compares two wide strings in accordance to the current locale
(function)[edit]
finds the first occurrence of a wide character in a wide string
(function)[edit]
finds the last occurrence of a wide character in a wide string
(function)[edit]
returns the length of the maximum initial segment that consists
of only the wide characters found in another wide string
(function)[edit]
returns the length of the maximum initial segment that consists
of only the wide not found in another wide string
(function)[edit]
finds the first location of any wide character in one wide string, in another wide string
(function)[edit]
finds the first occurrence of a wide string within another wide string
(function)[edit]
finds the next token in a wide string
(function)[edit]
Wide character array manipulation
copies a certain amount of wide characters between two non-overlapping arrays
(function)[edit]
copies a certain amount of wide characters between two, possibly overlapping, arrays
(function)[edit]
compares a certain amount of wide characters from two arrays
(function)[edit]
finds the first occurrence of a wide character in a wide character array
(function)[edit]
copies the given wide character to every position in a wide character array
(function)[edit]
Multibyte/wide character conversion
checks if the std::mbstate_t object represents initial shift state
(function)[edit]
widens a single-byte narrow character to wide character, if possible
(function)[edit]
narrows a wide character to a single-byte narrow character, if possible
(function)[edit]
returns the number of bytes in the next multibyte character, given state
(function)[edit]
converts the next multibyte character to wide character, given state
(function)[edit]
converts a wide character to its multibyte representation, given state
(function)[edit]
converts a narrow multibyte character string to wide string, given state
(function)[edit]
converts a wide string to narrow multibyte character string, given state
(function)[edit]
Input/Output
gets a wide character from a file stream
(function)[edit]
gets a wide string from a file stream
(function)[edit]
writes a wide character to a file stream
(function)[edit]
writes a wide string to a file stream
(function)[edit]
reads a wide character from stdin
(function)[edit]
writes a wide character to stdout
(function)[edit]
puts a wide character back into a file stream
(function)[edit]
switches a file stream between wide character I/O and narrow character I/O
(function)[edit]
reads formatted wide character input from stdin, a file stream or a buffer
(function)[edit]
(C++11)(C++11)(C++11)
reads formatted wide character input from stdin, a file stream
or a buffer using variable argument list
(function)[edit]
prints formatted wide character output to stdout, a file stream or a buffer
(function)[edit]
prints formatted wide character output to stdout, a file stream
or a buffer using variable argument list
(function)[edit]
String conversions
converts a std::tm object to custom wide string textual representation
(function)[edit]
converts a wide string to an integer value
(function)[edit]
converts a wide string to an unsigned integer value
(function)[edit]
converts a wide string to a floating-point value
(function)[edit]

[edit]Notes

[edit]Synopsis

namespace std {using size_t =/* see description */;// freestandingusing mbstate_t =/* see description */;// freestandingusing wint_t =/* see description */;// freestanding   struct tm;   int fwprintf(FILE* stream, constwchar_t* format, ...);int fwscanf(FILE* stream, constwchar_t* format, ...);int swprintf(wchar_t* s, size_t n, constwchar_t* format, ...);int swscanf(constwchar_t* s, constwchar_t* format, ...);int vfwprintf(FILE* stream, constwchar_t* format, va_list arg);int vfwscanf(FILE* stream, constwchar_t* format, va_list arg);int vswprintf(wchar_t* s, size_t n, constwchar_t* format, va_list arg);int vswscanf(constwchar_t* s, constwchar_t* format, va_list arg);int vwprintf(constwchar_t* format, va_list arg);int vwscanf(constwchar_t* format, va_list arg);int wprintf(constwchar_t* format, ...);int wscanf(constwchar_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(constwchar_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(constwchar_t* nptr, wchar_t** endptr);float wcstof(constwchar_t* nptr, wchar_t** endptr);longdouble wcstold(constwchar_t* nptr, wchar_t** endptr);longint wcstol(constwchar_t* nptr, wchar_t** endptr, int base);longlongint wcstoll(constwchar_t* nptr, wchar_t** endptr, int base);unsignedlongint wcstoul(constwchar_t* nptr, wchar_t** endptr, int base);unsignedlonglongint wcstoull(constwchar_t* nptr, wchar_t** endptr, int base);wchar_t* wcscpy(wchar_t* s1, constwchar_t* s2);// freestandingwchar_t* wcsncpy(wchar_t* s1, constwchar_t* s2, size_t n);// freestandingwchar_t* wmemcpy(wchar_t* s1, constwchar_t* s2, size_t n);// freestandingwchar_t* wmemmove(wchar_t* s1, constwchar_t* s2, size_t n);// freestandingwchar_t* wcscat(wchar_t* s1, constwchar_t* s2);// freestandingwchar_t* wcsncat(wchar_t* s1, constwchar_t* s2, size_t n);// freestandingint wcscmp(constwchar_t* s1, constwchar_t* s2);// freestandingint wcscoll(constwchar_t* s1, constwchar_t* s2);int wcsncmp(constwchar_t* s1, constwchar_t* s2, size_t n);// freestanding size_t wcsxfrm(wchar_t* s1, constwchar_t* s2, size_t n);int wmemcmp(constwchar_t* s1, constwchar_t* s2, size_t n);// freestandingconstwchar_t* wcschr(constwchar_t* s, wchar_t c);// freestandingwchar_t* wcschr(wchar_t* s, wchar_t c);// freestanding size_t wcscspn(constwchar_t* s1, constwchar_t* s2);// freestandingconstwchar_t* wcspbrk(constwchar_t* s1, constwchar_t* s2);// freestandingwchar_t* wcspbrk(wchar_t* s1, constwchar_t* s2);// freestandingconstwchar_t* wcsrchr(constwchar_t* s, wchar_t c);// freestandingwchar_t* wcsrchr(wchar_t* s, wchar_t c);// freestanding size_t wcsspn(constwchar_t* s1, constwchar_t* s2);// freestandingconstwchar_t* wcsstr(constwchar_t* s1, constwchar_t* s2);// freestandingwchar_t* wcsstr(wchar_t* s1, constwchar_t* s2);// freestandingwchar_t* wcstok(wchar_t* s1, constwchar_t* s2, wchar_t** ptr);// freestandingconstwchar_t* wmemchr(constwchar_t* s, wchar_t c, size_t n);// freestandingwchar_t* wmemchr(wchar_t* s, wchar_t c, size_t n);// freestanding size_t wcslen(constwchar_t* s);// freestandingwchar_t* wmemset(wchar_t* s, wchar_t c, size_t n);// freestanding size_t wcsftime(wchar_t* s, size_t maxsize, constwchar_t* format, const tm* timeptr); wint_t btowc(int c);int wctob(wint_t c);   // multibyte / wide string and character conversion functionsint mbsinit(const mbstate_t* ps); size_t mbrlen(constchar* s, size_t n, mbstate_t* ps); size_t mbrtowc(wchar_t* pwc, constchar* s, size_t n, mbstate_t* ps); size_t wcrtomb(char* s, wchar_t wc, mbstate_t* ps); size_t mbsrtowcs(wchar_t* dst, constchar** src, size_t len, mbstate_t* ps); size_t wcsrtombs(char* dst, constwchar_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

[edit]Defect reports

The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

DR Applied to Behavior as published Correct behavior
LWG 345C++98 std::tm was not provided in <cwchar>provided
close