Mbsrtowcs
mbsrtowcs is a C standard-library function that converts a restartable multibyte character string to a wide-character string.
Modern C
mbsrtowcs is a C standard library function that converts a restartable multibyte string to a wide-character string.
- How it is used
- Converts multibyte strings for character counting and wide-character string processing.
- How deep it goes
- Shows counting and allocation calls, including conversion-state copies and error checks, without implementing the library function itself.
- Examples
- Uses mbsrlen to count characters and mbsrdup to allocate and fill a wide-character string.
- What you can do after
- Apply it via the C standard library to count multibyte-string characters and populate an allocated wide-character string.
Modern C, Third Edition
mbsrtowcs is a C standard-library function that converts a multibyte string to a wide character string while maintaining conversion state.
- How it is used
- Converts multibyte strings into wide character strings for extended-character processing.
- How deep it goes
- Explains the interface, state handling, length-query idiom, allocation pattern, and invalid-source handling without detailing implementation internals.
- Examples
- Demonstrates zero-length counting through mbsrlen and allocated conversion through mbsrdup.
- What you can do after
- Build converted wide strings and determine their required length while preserving conversion state.
Related concepts
- wide character stringproduces · A wide-character string is a null-terminated array of wchar_t values representing a sequence of wide characters.
- mbrtowcalternative to · mbrtowc is a C standard-library function that converts a multibyte character sequence to a wide character while maintaining restartable conversion state.
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.

