mbtowc

Converts a single multibyte character into the wide-character code that corresponds to that multibyte character.

Library:LibC
Classification:ANSI
Service:General C Services

Syntax

  #include <stdlib.h> 
   
  int mbtowc (
     wchar_t      *pwc,   
     const char   *s,   
     size_t        n);
  

Parameters

pwc

(OUT) Points to a wide-character code.

s

(IN) Points to the array of multibyte characters to be converted.

n

(IN) Specifies the number of bytes of the array pointed to by s to be examined.

Return Values

If successful, returns the length in bytes of the multibyte character. Otherwise, returns 0 for any of the following conditions:

If a valid multibyte character is not encountered within n bytes, returns -1.

Remarks

The mbtowc function converts a single multibyte character pointed to by s into the wide-character code that corresponds to that multibyte character.

The code for the null-terminating character is zero. If the multibyte character is valid and pwc is not a NULL pointer, the code is stored in the object pointed to by pwc. At most, n bytes of the array pointed to by s are examined.

See Also

wctomb