Convert a multibyte character (UTF-8) into a wide character (UTF-16 or
UTF-32)
Synopsis:
#include <uchar.h>
size_t mbrtoc16( char16_t *pwc,
const char *s,
size_t n,
mbstate_t *ps);
size_t mbrtoc32( char32_t *pwc,
const char *s,
size_t n,
mbstate_t *ps);
Arguments:
- pwc
- A pointer to a location where the function can store the wide character.
- s
- NULL, or an array of characters that make up a multibyte character.
- n
- The maximum number of bytes to convert from the multibyte character.
- ps
- A pointer to a conversion object that's used to store state information so that the function can be restarted.
You can call
mbsinit()
to determine the status of this variable.
Note: If the s argument is NULL, the values of
pwc and n will be ignored and the call is equivalent
to mbrtoc16 (NULL, "", 1, ps) or mbrtoc32 (NULL, "", 1, ps).
Library:
libc
Use the -l c option to
qcc
to link against this library.
This library is usually included automatically.
Description:
The mbrtoc16() and mbrtoc32() functions
determine the number of bytes in the multibyte string s that complete the next
multibyte character, if possible.
If pwc isn't NULL, the functions actually do the conversion (from UTF-8 to UTF-16 for type char16_t
or UTF-32 for type char32_t).
Returns:
The number of bytes needed to complete the next multibyte character, or:
- (size_t)-3 if no additional bytes are needed to complete the next multibyte character,
in which case the resulting conversion state indicates that no additional bytes have been converted,
and the next multibyte character has been produced
- (size_t)-2 if, after converting all n characters, the resulting
conversion state indicates an incomplete multibyte character
- (size_t)-1 if the function detects an encoding error before completing the next
multibyte character, in which case the function stores the value EILSEQ in
errno
and leaves the resulting conversion state undefined
- 0, if the next completed character is a null character, in which case the resulting conversion state
is the initial conversion state
Classification:
C11
Safety: |
|
Cancellation point |
No |
Interrupt handler |
No |
Signal handler |
Yes |
Thread |
Yes |