C Language: mbtowc function
(Convert Multibyte Character to Wide Character)
In the C Programming Language, the mbtowc function converts a multibyte character (as pointed to by s) into a wide character (as pointed to by pwc) up to n codes in length.
Syntax
The syntax for the mbtowc function in the C Language is:
int mbtowc(wchar_t *pwc, const char *s, size_t n);
Parameters or Arguments
- pwc
- he array where the converted wide character will be stored.
- s
- The multibyte character to convert into a wide character.
- n
- The maximum number of bytes to store in pwc.
Note
- If s is a null pointer, the mbtowc function will initialize the shift state.
mbtowc function - Returns
The mbtowc function looks at the first n bytes and if it forms a valid character, it returns the number of bytes in s. If it is not, the mbtowc function returns -1. The mbtowc function returns zero if s points to a null character.
Required Header
In the C Language, the required header for the mbtowc function is:
#include <stdlib.h>
Applies To
In the C Language, the mbtowc function can be used in the following versions:
- ANSI/ISO 9899-1990
Similar Functions
Other C functions that are similar to the mbtowc function:
See Also
Other C functions that are noteworthy when dealing with the mbtowc function:
Advertisements