Wide character string
A wide-character string is a null-terminated array of wchar_t values representing a sequence of wide characters.
Modern C
A wide character string is a null-terminated array of wchar_t elements representing a sequence of wide characters.
- How it is used
- Provides a destination for converting multibyte strings into sequences of wide characters.
- How deep it goes
- Works through length calculation and allocation for conversion, without developing a general wide-string interface.
- Examples
- Uses a conversion function that allocates mblen + 1 wchar_t elements and calls mbsrtowcs.
- What you can do after
- Build it from scratch by counting multibyte characters, allocating space for a terminator, and converting with mbsrtowcs.
Modern C, Third Edition
A wide character string is a null-terminated array of wchar_t values representing characters from an extended character set.
- How it is used
- Handles extended-character strings when ordinary byte-string operations are insufficient.
- How deep it goes
- Defines representation and conversion, then addresses string functions, invalid input, and wchar_t portability without fully specifying encodings.
- Examples
- Uses mbsrdup to allocate and populate a wide string after measuring a multibyte source.
- What you can do after
- Apply it via C library functions to convert multibyte strings and perform wide-character string operations.
Read how Modern C, Third Edition explains wide character string →
Related concepts
- mbsrtowcsproduced by · mbsrtowcs is a C standard-library function that converts a restartable multibyte character string to a wide-character string.
- stringkind of · A string is a programming-language value representing an ordered sequence of characters or character units as text.
- wide characterhas part · A wide character is a value of type wchar_t representing one character from an extended character set.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

