mbtowc function(Convert Multibyte Character to Wide Character) in C Language – example and detail

In the C Programming Language, the mbtowc characteristic converts a multibyte persona (as pointed to by using s) into a broad persona (as pointed to by using pwc) up to n codes in length.

Syntax

The syntax for the mbtowc feature in the C Language is:

int mbtowc(wchar_t *pwc, const char *s, size_t n);

Parameters or Arguments

pwc he array where the transformed large character will be stored. s The multibyte character to convert into a extensive character. n The most number of bytes to save in pwc.

Note If s is a null pointer, the mbtowc characteristic 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 range of bytes in s. If it is not, the mbtowc characteristic 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 characteristic is:

#include <stdlib.h>

Applies To

In the C Language, the mbtowc characteristic can be used in the following versions:

ANSI/ISO 9899-1990

Similar Functions

Other C features that are similar to the mbtowc function:

mblen feature wctomb characteristic

See Also

Other C functions that are noteworthy when dealing with the mbtowc function:

mbstowcs characteristic setlocale characteristic wcstombs feature