[text.c.strings]

# 28 Text processing library [[text]](./#text)

## 28.7 Null-terminated sequence utilities [text.c.strings]

### [28.7.1](#cctype.syn) Header <cctype> synopsis [[cctype.syn]](cctype.syn)

[ð](#lib:isalnum)

namespace std {int isalnum(int c); int isalpha(int c); int isblank(int c); int iscntrl(int c); int isdigit(int c); int isgraph(int c); int islower(int c); int isprint(int c); int ispunct(int c); int isspace(int c); int isupper(int c); int isxdigit(int c); int tolower(int c); int toupper(int c);}

[1](#cctype.syn-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L13029)

The contents and meaning of the header <cctype> are the same as the C standard library header [<ctype.h>](support.c.headers.general#header:%3cctype.h%3e "17.15.1 General [support.c.headers.general]")[.](#cctype.syn-1.sentence-1)

See also: ISO/IEC 9899:2024, 7.4

### [28.7.2](#cwctype.syn) Header <cwctype> synopsis [[cwctype.syn]](cwctype.syn)

[ð](#lib:wint_t)

namespace std {using wint_t = *see below*; using wctrans_t = *see below*; using wctype_t = *see below*; int iswalnum(wint_t wc); int iswalpha(wint_t wc); int iswblank(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);}#define WEOF *see below*

[1](#cwctype.syn-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L13087)

The contents and meaning of the header <cwctype> are the same as the C standard library header [<wctype.h>](support.c.headers.general#header:%3cwctype.h%3e "17.15.1 General [support.c.headers.general]")[.](#cwctype.syn-1.sentence-1)

See also: ISO/IEC 9899:2024, 7.32

### [28.7.3](#cwchar.syn) Header <cwchar> synopsis [[cwchar.syn]](cwchar.syn)

[ð](#header:%3ccwchar%3e)

#define __STDC_VERSION_WCHAR_H__ 202311Lnamespace std {using size_t = *see [[support.types.layout]](support.types.layout "17.2.4 Sizes, alignments, and offsets")*; // freestandingusing mbstate_t = *see below*; // freestandingusing wint_t = *see below*; // freestandingstruct 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); // freestandingwchar_t* wcsncpy(wchar_t* s1, const wchar_t* s2, size_t n); // freestandingwchar_t* wmemcpy(wchar_t* s1, const wchar_t* s2, size_t n); // freestandingwchar_t* wmemmove(wchar_t* s1, const wchar_t* s2, size_t n); // freestandingwchar_t* wcscat(wchar_t* s1, const wchar_t* s2); // freestandingwchar_t* wcsncat(wchar_t* s1, const wchar_t* s2, size_t n); // freestandingint wcscmp(const wchar_t* s1, const wchar_t* s2); // freestandingint 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); // freestandingconst wchar_t* wcschr(const wchar_t* s, wchar_t c); // freestanding; see [[library.c]](library.c "16.2 The C standard library")wchar_t* wcschr(wchar_t* s, wchar_t c); // freestanding; see [[library.c]](library.c "16.2 The C standard library") size_t wcscspn(const wchar_t* s1, const wchar_t* s2); // freestandingconst wchar_t* wcspbrk(const wchar_t* s1, const wchar_t* s2); // freestanding; see [[library.c]](library.c "16.2 The C standard library")wchar_t* wcspbrk(wchar_t* s1, const wchar_t* s2); // freestanding; see [[library.c]](library.c "16.2 The C standard library")const wchar_t* wcsrchr(const wchar_t* s, wchar_t c); // freestanding; see [[library.c]](library.c "16.2 The C standard library")wchar_t* wcsrchr(wchar_t* s, wchar_t c); // freestanding; see [[library.c]](library.c "16.2 The C standard library") size_t wcsspn(const wchar_t* s1, const wchar_t* s2); // freestandingconst wchar_t* wcsstr(const wchar_t* s1, const wchar_t* s2); // freestanding; see [[library.c]](library.c "16.2 The C standard library")wchar_t* wcsstr(wchar_t* s1, const wchar_t* s2); // freestanding; see [[library.c]](library.c "16.2 The C standard library")wchar_t* wcstok(wchar_t* s1, const wchar_t* s2, wchar_t** ptr); // freestandingconst wchar_t* wmemchr(const wchar_t* s, wchar_t c, size_t n); // freestanding; see [[library.c]](library.c "16.2 The C standard library")wchar_t* wmemchr(wchar_t* s, wchar_t c, size_t n); // freestanding; see [[library.c]](library.c "16.2 The C standard library") size_t wcslen(const wchar_t* s); // freestandingwchar_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); // [[c.mb.wcs]](#c.mb.wcs "28.7.5 Multibyte / wide string and character conversion functions"), multibyte / wide string and character conversion functionsint 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 [[support.types.nullptr]](support.types.nullptr "17.2.3 Null pointers")* // freestanding#define WCHAR_MAX *see below* // freestanding#define WCHAR_MIN *see below* // freestanding#define WEOF *see below* // freestanding#define WCHAR_WIDTH *see below* // freestanding

[1](#cwchar.syn-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L13244)

The contents and meaning of the header [<cwchar>](#header:%3ccwchar%3e "28.7.3 Header <cwchar> synopsis [cwchar.syn]") are the same as the C standard library header[<wchar.h>](support.c.headers.general#header:%3cwchar.h%3e "17.15.1 General [support.c.headers.general]"), except that it does not declare a type wchar_t[.](#cwchar.syn-1.sentence-1)

[2](#cwchar.syn-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L13249)

[*Note [1](#cwchar.syn-note-1)*:

The functionswcschr, wcspbrk, wcsrchr, wcsstr, and wmemchr have different signatures in this document,
but they have the same behavior as in the C standard library ([[library.c]](library.c "16.2 The C standard library"))[.](#cwchar.syn-2.sentence-1)

â *end note*]

See also: ISO/IEC 9899:2024, 7.31

### [28.7.4](#cuchar.syn) Header <cuchar> synopsis [[cuchar.syn]](cuchar.syn)

[ð](#lib:mbstate_t_)

#define __STDC_VERSION_UCHAR_H__ 202311Lnamespace std {using mbstate_t = *see below*; using size_t = *see [[support.types.layout]](support.types.layout "17.2.4 Sizes, alignments, and offsets")*;

 size_t mbrtoc8(char8_t* pc8, const char* s, size_t n, mbstate_t* ps);
 size_t c8rtomb(char* s, char8_t c8, mbstate_t* ps);
 size_t mbrtoc16(char16_t* pc16, const char* s, size_t n, mbstate_t* ps);
 size_t c16rtomb(char* s, char16_t c16, mbstate_t* ps);
 size_t mbrtoc32(char32_t* pc32, const char* s, size_t n, mbstate_t* ps);
 size_t c32rtomb(char* s, char32_t c32, mbstate_t* ps);}

[1](#cuchar.syn-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L13285)

The contents and meaning of the header <cuchar> are the same as the C standard library header [<uchar.h>](support.c.headers.general#header:%3cuchar.h%3e "17.15.1 General [support.c.headers.general]"),
except that it does not declare typeschar8_t, char16_t, or char32_t[.](#cuchar.syn-1.sentence-1)

See also: ISO/IEC 9899:2024, 7.30

### [28.7.5](#c.mb.wcs) Multibyte / wide string and character conversion functions [[c.mb.wcs]](c.mb.wcs)

[1](#c.mb.wcs-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L13295)

[*Note [1](#c.mb.wcs-note-1)*:

The headers [<cstdlib>](cstdlib.syn#header:%3ccstdlib%3e "17.2.2 Header <cstdlib> synopsis [cstdlib.syn]"),[<cuchar>](#header:%3ccuchar%3e "28.7.4 Header <cuchar> synopsis [cuchar.syn]"),
and [<cwchar>](#header:%3ccwchar%3e "28.7.3 Header <cwchar> synopsis [cwchar.syn]") declare the functions described in this subclause[.](#c.mb.wcs-1.sentence-1)

â *end note*]

[ð](#lib:mbsinit_)

`int mbsinit(const mbstate_t* ps);
int mblen(const char* s, size_t n);
size_t mbstowcs(wchar_t* pwcs, const char* s, size_t n);
size_t wcstombs(char* s, const wchar_t* pwcs, size_t n);
`

[2](#c.mb.wcs-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L13315)

*Effects*: These functions have the semantics specified in the C standard library[.](#c.mb.wcs-2.sentence-1)

See also: ISO/IEC 9899:2024, 7.22.7.1, 7.22.8, 7.29.6.2.1

[ð](#lib:mbtowc)

`int mbtowc(wchar_t* pwc, const char* s, size_t n);
int wctomb(char* s, wchar_t wchar);
`

[3](#c.mb.wcs-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L13330)

*Effects*: These functions have the semantics specified in the C standard library[.](#c.mb.wcs-3.sentence-1)

[4](#c.mb.wcs-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L13334)

*Remarks*: Calls to these functions
may introduce a data race ([[res.on.data.races]](res.on.data.races "16.4.6.10 Data race avoidance"))
with other calls to the same function[.](#c.mb.wcs-4.sentence-1)

See also: ISO/IEC 9899:2024, 7.22.7

[ð](#c.mb.wcs-itemdecl:3)

`size_t [mbrlen](#lib:mbrlen "28.7.5 Multibyte / wide string and character conversion functions [c.mb.wcs]")(const char* s, size_t n, mbstate_t* ps);
size_t [mbrtowc](#lib:mbrtowc "28.7.5 Multibyte / wide string and character conversion functions [c.mb.wcs]")(wchar_t* pwc, const char* s, size_t n, mbstate_t* ps);
size_t [wcrtomb](#lib:wcrtomb "28.7.5 Multibyte / wide string and character conversion functions [c.mb.wcs]")(char* s, wchar_t wc, mbstate_t* ps);
size_t [mbrtoc8](#lib:mbrtoc8 "28.7.5 Multibyte / wide string and character conversion functions [c.mb.wcs]")(char8_t* pc8, const char* s, size_t n, mbstate_t* ps);
size_t [c8rtomb](#lib:c8rtomb "28.7.5 Multibyte / wide string and character conversion functions [c.mb.wcs]")(char* s, char8_t c8, mbstate_t* ps);
size_t [mbrtoc16](#lib:mbrtoc16 "28.7.5 Multibyte / wide string and character conversion functions [c.mb.wcs]")(char16_t* pc16, const char* s, size_t n, mbstate_t* ps);
size_t [c16rtomb](#lib:c16rtomb "28.7.5 Multibyte / wide string and character conversion functions [c.mb.wcs]")(char* s, char16_t c16, mbstate_t* ps);
size_t [mbrtoc32](#lib:mbrtoc32 "28.7.5 Multibyte / wide string and character conversion functions [c.mb.wcs]")(char32_t* pc32, const char* s, size_t n, mbstate_t* ps);
size_t [c32rtomb](#lib:c32rtomb "28.7.5 Multibyte / wide string and character conversion functions [c.mb.wcs]")(char* s, char32_t c32, mbstate_t* ps);
size_t [mbsrtowcs](#lib:mbsrtowcs "28.7.5 Multibyte / wide string and character conversion functions [c.mb.wcs]")(wchar_t* dst, const char** src, size_t len, mbstate_t* ps);
size_t [wcsrtombs](#lib:wcsrtombs "28.7.5 Multibyte / wide string and character conversion functions [c.mb.wcs]")(char* dst, const wchar_t** src, size_t len, mbstate_t* ps);
`

[5](#c.mb.wcs-5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L13358)

*Effects*: These functions have the semantics specified in the C standard library[.](#c.mb.wcs-5.sentence-1)

[6](#c.mb.wcs-6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L13362)

*Remarks*: Calling these functions
with an mbstate_t* argument that is a null pointer value
may introduce a data race ([[res.on.data.races]](res.on.data.races "16.4.6.10 Data race avoidance"))
with other calls to the same function
with an mbstate_t* argument that is a null pointer value[.](#c.mb.wcs-6.sentence-1)

See also: ISO/IEC 9899:2024, 7.30.1, 7.31.6.3, 7.31.6.4
