mbsrtowcs
mbsrtowcs is a C standard library function used to convert a multibyte sequence into a wide-character string. It is declared in <wchar.h> and is designed for use with multibyte encodings (such as UTF-8) in conjunction with a locale. The function supports streaming conversion, allowing input to be processed piece by piece.
size_t mbsrtowcs(wchar_t *restrict pwcs, const char **restrict s, size_t len, mbstate_t *restrict ps);
- pwcs: destination array for wide characters. If pwcs is NULL, no writing occurs and the function
- s: pointer to a pointer to the input multibyte string. The function reads from *s and advances
- len: maximum number of wide characters to write to pwcs (if pwcs is non-null).
- ps: a pointer to an mbstate_t object that records the conversion state. The state enables correct
mbsrtowcs converts as many complete multibyte characters as possible from the input into wide characters, up
mbsrtowcs is part of the mbrtowc/mbsrtowcs family, used for converting multibyte strings to wide-character representations. It
The function is provided by standard C libraries on modern systems and is suitable for locale-aware