C++ <cwctype> - WEOF constant
The C++ <cwctype> WEOF is a macro constant definition of type wint_t that expands into a constant expression whose value does not correspond to any character of wide character set.
It is used as the value returned by several wide character functions to indicate either the End-of-File has been reached, or to indicate a character value not corresponding to any member of the wide character set.
This macro constant is also defined in header <cwchar>.
Example:
The example below shows one of the usage of WEOF macro constant.
#include <cwctype> #include <cwchar> void try_widen(unsigned char c) { //wint_t type is used to hold the character //value of the wide character set wint_t wc = btowc(c); //WEOF is used to check whether the widening of //character was successful or not if(wc != WEOF) wprintf(L"Single-byte character %#x widens to %#x\n", c, wc); else wprintf(L"Single-byte character %#x failed to widen\n", c); } int main (){ try_widen('A'); try_widen('\t'); try_widen(0xf9); try_widen(0xdf); return 0; }
The output of the above code will be:
Single-byte character 0x41 widens to 0x41 Single-byte character 0x9 widens to 0x9 Single-byte character 0xf9 failed to widen Single-byte character 0xdf failed to widen
❮ C++ <cwctype> Library