Name
mbtowc function — Converts multibyte character to wide character
Synopsis
int mbtowc(wchar_t* pwc, const char* src, size_t n)
The mbtowc
function
converts a multibyte character sequence to a single wide character.
It starts by counting the number of bytes in src
that make up the first multibyte
character. It examines only the first n
bytes.
If src
is null, the return
value depends on whether multibyte characters have state-dependent
encodings. (See Chapter 8 for a
discussion of shift state.) The mbtowc
function returns a nonzero value if
encodings are state-dependent or 0
if encodings are not
state-dependent.
If src
points to an empty
string, 0
is returned.
If src
points to a valid
multibyte character, the number of bytes that make up that character
is returned. If dst
is not null,
the multibyte character is converted to its equivalent wide
character, and the wide character is stored in *dst
.
If src
points to an invalid
multibyte character, -1
is
returned.
See Also
mblen function, mbstowcs function, wctomb function, mbrtowc
in <cwchar>
Get C++ In a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.