wchar.h(0P)
π PROLOG π
okay so bestie, first things first: this page is part of the POSIX Programmer's Manual. But real talk β the Linux implementation of this interface may differ (so go consult the corresponding Linux manual page for the actual Linux behavior tea), or honestly the interface may not be implemented on Linux at all. π
β¨ NAME β¨
wchar.h β wide-character handling π
πΈ SYNOPSIS πΈ
#include <wchar.h>
π DESCRIPTION π
Some of the functionality described on this reference page is literally extending the ISO C standard, and the way that works is: applications shall define the appropriate feature test macro (peep the System Interfaces volume of POSIX.1β2017, Section 2.2, The Compilation Environment) to enable the visibility of these symbols in this header. periodt. β¨
The <wchar.h> header shall define the following types, and bestie, they're all kinda iconic:
FILEβ as described in<stdio.h>. πlocale_tβ as described in<locale.h>.mbstate_tβ an object type that is not an array type, and it can hold the conversion state information you need to convert between sequences of (possibly multi-byte) characters and wide characters. Heads up though: if a codeset is being used such that anmbstate_tneeds to preserve more than two levels of reserved state, the results are unspecified. πsize_tβ as described in<stddef.h>.va_listβ as described in<stdarg.h>.wchar_tβ as described in<stddef.h>.wctype_tβ a scalar type of a data object that can hold values which represent locale-specific character classification. she classifies, she slays. πwint_tβ an integer type capable of storing any valid value ofwchar_torWEOF.
The tag tm shall be declared as naming an incomplete structure type, and the contents of it are described in the <time.h> header.
Also, the implementation shall support one or more programming environments in which the width of wint_t is no greater than the width of type long. You can get the names of these programming environments using the confstr() function or the getconf utility. iykyk. π₯
Then the <wchar.h> header shall define the following macros:
WCHAR_MAXβ as described in<stdint.h>.WCHAR_MINβ as described in<stdint.h>.WEOFβ a constant expression of typewint_tthat is returned by several WP functions to indicate end-of-file. bye bestie πNULLβ as described in<stddef.h>.
Inclusion of the <wchar.h> header may make visible all symbols from the headers <ctype.h>, <string.h>, <stdarg.h>, <stddef.h>, <stdio.h>, <stdlib.h>, and <time.h>. not it just casually leaking symbols from seven other headers π
The following shall be declared as functions and may also be defined as macros. Function prototypes shall be provided for use with ISO C standard compilers. And this is important, okay: arguments to functions in this list can point to arrays containing wchar_t values that do not correspond to members of the character set of the current locale. Such values shall be processed according to the specified semantics, unless otherwise stated.
wint_t btowc(int);
wint_t fgetwc(FILE *);
wchar_t *fgetws(wchar_t *restrict, int, FILE *restrict);
wint_t fputwc(wchar_t, FILE *);
int fputws(const wchar_t *restrict, FILE *restrict);
int fwide(FILE *, int);
int fwprintf(FILE *restrict, const wchar_t *restrict, ...);
int fwscanf(FILE *restrict, const wchar_t *restrict, ...);
wint_t getwc(FILE *);
wint_t getwchar(void);
int iswalnum(wint_t);
int iswalpha(wint_t);
int iswcntrl(wint_t);
int iswctype(wint_t, wctype_t);
int iswdigit(wint_t);
int iswgraph(wint_t);
int iswlower(wint_t);
int iswprint(wint_t);
int iswpunct(wint_t);
int iswspace(wint_t);
int iswupper(wint_t);
int iswxdigit(wint_t);
size_t mbrlen(const char *restrict, size_t, mbstate_t *restrict);
size_t mbrtowc(wchar_t *restrict, const char *restrict, size_t,
mbstate_t *restrict);
int mbsinit(const mbstate_t *);
size_t mbsnrtowcs(wchar_t *restrict, const char **restrict,
size_t, size_t, mbstate_t *restrict);
size_t mbsrtowcs(wchar_t *restrict, const char **restrict, size_t,
mbstate_t *restrict);
FILE *open_wmemstream(wchar_t **, size_t *);
wint_t putwc(wchar_t, FILE *);
wint_t putwchar(wchar_t);
int swprintf(wchar_t *restrict, size_t,
const wchar_t *restrict, ...);
int swscanf(const wchar_t *restrict,
const wchar_t *restrict, ...);
wint_t towlower(wint_t);
wint_t towupper(wint_t);
wint_t ungetwc(wint_t, FILE *);
int vfwprintf(FILE *restrict, const wchar_t *restrict, va_list);
int vfwscanf(FILE *restrict, const wchar_t *restrict, va_list);
int vswprintf(wchar_t *restrict, size_t,
const wchar_t *restrict, va_list);
int vswscanf(const wchar_t *restrict, const wchar_t *restrict,
va_list);
int vwprintf(const wchar_t *restrict, va_list);
int vwscanf(const wchar_t *restrict, va_list);
wchar_t *wcpcpy(wchar_t *restrict, const wchar_t *restrict);
wchar_t *wcpncpy(wchar_t *restrict, const wchar_t *restrict, size_t);
size_t wcrtomb(char *restrict, wchar_t, mbstate_t *restrict);
int wcscasecmp(const wchar_t *, const wchar_t *);
int wcscasecmp_l(const wchar_t *, const wchar_t *, locale_t);
wchar_t *wcscat(wchar_t *restrict, const wchar_t *restrict);
wchar_t *wcschr(const wchar_t *, wchar_t);
int wcscmp(const wchar_t *, const wchar_t *);
int wcscoll(const wchar_t *, const wchar_t *);
int wcscoll_l(const wchar_t *, const wchar_t *, locale_t);
wchar_t *wcscpy(wchar_t *restrict, const wchar_t *restrict);
size_t wcscspn(const wchar_t *, const wchar_t *);
wchar_t *wcsdup(const wchar_t *);
size_t wcsftime(wchar_t *restrict, size_t,
const wchar_t *restrict, const struct tm *restrict);
size_t wcslen(const wchar_t *);
int wcsncasecmp(const wchar_t *, const wchar_t *, size_t);
int wcsncasecmp_l(const wchar_t *, const wchar_t *, size_t,
locale_t);
wchar_t *wcsncat(wchar_t *restrict, const wchar_t *restrict, size_t);
int wcsncmp(const wchar_t *, const wchar_t *, size_t);
wchar_t *wcsncpy(wchar_t *restrict, const wchar_t *restrict, size_t);
size_t wcsnlen(const wchar_t *, size_t);
size_t wcsnrtombs(char *restrict, const wchar_t **restrict, size_t,
size_t, mbstate_t *restrict);
wchar_t *wcspbrk(const wchar_t *, const wchar_t *);
wchar_t *wcsrchr(const wchar_t *, wchar_t);
size_t wcsrtombs(char *restrict, const wchar_t **restrict,
size_t, mbstate_t *restrict);
size_t wcsspn(const wchar_t *, const wchar_t *);
wchar_t *wcsstr(const wchar_t *restrict, const wchar_t *restrict);
double wcstod(const wchar_t *restrict, wchar_t **restrict);
float wcstof(const wchar_t *restrict, wchar_t **restrict);
wchar_t *wcstok(wchar_t *restrict, const wchar_t *restrict,
wchar_t **restrict);
long wcstol(const wchar_t *restrict, wchar_t **restrict, int);
long double wcstold(const wchar_t *restrict, wchar_t **restrict);
long long wcstoll(const wchar_t *restrict, wchar_t **restrict, int);
unsigned long wcstoul(const wchar_t *restrict, wchar_t **restrict, int);
unsigned long long
wcstoull(const wchar_t *restrict, wchar_t **restrict, int);
int wcswidth(const wchar_t *, size_t);
size_t wcsxfrm(wchar_t *restrict, const wchar_t *restrict, size_t);
size_t wcsxfrm_l(wchar_t *restrict, const wchar_t *restrict,
size_t, locale_t);
int wctob(wint_t);
wctype_t wctype(const char *);
int wcwidth(wchar_t);
wchar_t *wmemchr(const wchar_t *, wchar_t, size_t);
int wmemcmp(const wchar_t *, const wchar_t *, size_t);
wchar_t *wmemcpy(wchar_t *restrict, const wchar_t *restrict, size_t);
wchar_t *wmemmove(wchar_t *, const wchar_t *, size_t);
wchar_t *wmemset(wchar_t *, wchar_t, size_t);
int wprintf(const wchar_t *restrict, ...);
int wscanf(const wchar_t *restrict, ...);
The following sections are informative. (translation: the juicy bits are done, this is the ~lore~ πΈ)
π APPLICATION USAGE π
So here's the backstory bestie, and it's giving drama: the iswblank() function was a late addition to the ISO C standard, and it showed up at the exact same time the ISO C standard introduced <wctype.h>, which contains all of the isw*() functions. Meanwhile, The Open Group Base Specifications had previously aligned with the MSE working draft and had introduced the rest of the isw*() functions into <wchar.h>. messy, ik. π
So for backwards-compatibility, the original set of isw*() functions, without iswblank(), are permitted (as part of the XSI option) in <wchar.h>. But β and this matters β for maximum portability, applications should include <wctype.h> in order to obtain declarations for the isw*() functions. And ngl, this compatibility has been made obsolescent. π
π¦ RATIONALE π¦
In the ISO C standard, the symbols referenced as XSI extensions live in <wctype.h>. So their presence here is thus an extension. that's it, that's the whole reason π
β FUTURE DIRECTIONS β
None.
π SEE ALSO π
The vibe-adjacent headers, all gathered for you:
<ctype.h><locale.h><stdarg.h><stddef.h><stdint.h><stdio.h><stdlib.h><string.h><time.h><wctype.h>
The System Interfaces volume of POSIX.1β2017, Section 2.2, The Compilation Environment, btowc(), confstr(), fgetwc(), fgetws(), fputwc(), fputws(), fwide(), fwprintf(), fwscanf(), getwc(), getwchar(), iswalnum(), iswalpha(), iswcntrl(), iswctype(), iswdigit(), iswgraph(), iswlower(), iswprint(), iswpunct(), iswspace(), iswupper(), iswxdigit(), mbrlen(), mbrtowc(), mbsinit(), mbsrtowcs(), open_memstream(), putwc(), putwchar(), towlower(), towupper(), ungetwc(), vfwprintf(), vfwscanf(), wcrtomb(), wcscasecmp(), wcscat(), wcschr(), wcscmp(), wcscoll(), wcscpy(), wcscspn(), wcsdup(), wcsftime(), wcslen(), wcsncat(), wcsncmp(), wcsncpy(), wcspbrk(), wcsrchr(), wcsrtombs(), wcsspn(), wcsstr(), wcstod(), wcstok(), wcstol(), wcstoul(), wcswidth(), wcsxfrm(), wctob(), wctype(), wcwidth(), wmemchr(), wmemcmp(), wmemcpy(), wmemmove(), wmemset()
The Shell and Utilities volume of POSIX.1β2017, getconf π«Ά
and that's part 1 bestie!! there's MORE, so don't go anywhere πβ¨
π COPYRIGHT π
okay bestie, legal era incoming, stay with me π
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. fr fr that's the whole credit chain, no cap.
π¨ real talk: if this version and the original IEEE / The Open Group Standard ever disagree? The original IEEE and The Open Group Standard is the referee document. Like, it's the main character, this page is just the cover. periodt.
You can grab the original Standard online at http://www.opengroup.org/unix/online.html β¨
π«Ά about the typos (yes, they exist, be nice)
Any typographical or formatting errors hanging out on this page were most likely introduced during the conversion of the source files to man page format. Not a vibe, but it happens π
Wanna report one? See https://www.kernel.org/doc/man-pages/reporting_bugs.html and tell the nice maintainers ππ
that's the whole page, bestie, you made it to the end π thanks for reading all of it, you're literally iconic for that π
this came from the IEEE/The Open Group gang, dated 2017, and it lives as page wchar.h(0P) in the manual. slay, go write some wide-character code ππ
π¦ where this page comes from
- alpine 3.22: man-pages-posix 2017a-r0 Β· custom
- alpine 3.23: man-pages-posix 2017a-r0 Β· custom
- alpine 3.24: man-pages-posix 2017a-r0 Β· custom
- arch rolling: man-pages 6.19-1
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages-posix 2017a
- opensuse-leap 16.0: man-pages-posix 2017a-160000.4.1 Β· SUSE-IEEE
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms