Mbrtowc
mbrtowc is a C standard-library function that converts a multibyte character sequence to a wide character while maintaining restartable conversion state.
Modern C
mbrtowc is a C standard library function that converts one multibyte character to a wide character while tracking conversion state.
- How it is used
- Supports character-by-character conversion while scanning multibyte strings.
- How deep it goes
- Explains the byte limit, conversion state, and key return values through a wrapper; leaves encoding details machine-dependent.
- Examples
- Traces a wrapper that enlarges the byte limit after -2 and feeds a wide-character string search.
- What you can do after
- Apply it to convert successive multibyte characters, handling insufficient input separately from encoding errors.
Modern C, Third Edition
mbrtowc is a C standard-library conversion function that converts a multibyte character sequence to a wide character while maintaining restartable conversion state.
- How it is used
- Parses one multibyte character when conversion requires finer control than whole-string conversion.
- How deep it goes
- Explains the signature, scan limit, incomplete result, and adaptive-length wrapper without detailing encoding algorithms.
- Examples
- Uses a mbrtow wrapper that retries with increasing limits and reports mbinvalid after conversion failure.
- What you can do after
- Apply mbrtowc to inspect multibyte input incrementally and respond to incomplete or invalid characters.
Related concepts
- wide characterproduces · A wide character is a value of type wchar_t representing one character from an extended character set.
- mbsrtowcsalternative to · mbsrtowcs is a C standard-library function that converts a restartable multibyte character string to a wide-character string.
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.

