Manpage of MBRTOWC
MBRTOWCSection: Linux Programmer's Manual (3)
NAMEmbrtowc - convert a multibyte sequence to a wide character
#include <wchar.h>size_t mbrtowc(wchar_t *pwc, const char *s, size_t n, mbstate_t *ps);
DESCRIPTIONThe main case for this function is when sis not NULL and pwcis not NULL. In this case, the mbrtowc() function inspects at most nbytes of the multibyte string starting at s, extracts the complete multibyte character, converts it to a wide character and stores it at *pwc. It updates the shift state *ps. If the converted wide character is not Laq\0aq (the null wide character), it returns the number of bytes that were consumed from s. If the converted wide character is Laq\0aq, it resets the shift state *psto the initial state and returns 0.
If the nbytes starting at sdo not contain a complete multibyte character, mbrtowc() returns (size_t) -2. This can happen even if n>= MB_CUR_MAX, if the multibyte string contains redundant shift sequences.
If the multibyte string starting at scontains an invalid multibyte sequence before thecomplete character, mbrtowc() returns (size_t) -1and sets errnoto EILSEQ. In this case, the effects on *psare undefined.
A different case is when sis not NULL but pwcis NULL. In this case, the mbrtowc() function behaves as above, except that it does not store the converted wide character in memory.
A third case is when sis NULL. In this case, pwcand nare ignored. If the conversion state represented by *psdenotes an incomplete multibyte character conversion, the mbrtowc() function returns (size_t) -1, sets errnoto EILSEQ, and leaves *psin an undefined state. Otherwise, the mbrtowc() function puts *psin the initial state and returns 0.
In all of the above cases, if psis NULL, a static anonymous state known only to the mbrtowc() function is used instead. Otherwise, *psmust be a valid mbstate_tobject. An mbstate_tobject acan be initialized to the initial state by zeroing it, for example using
RETURN VALUEThe mbrtowc() function returns the number of bytes parsed from the multibyte sequence starting at s, if a non-Laq\0aq wide character was recognized. It returns 0, if a Laq\0aq wide character was recognized. It returns (size_t) -1and sets errnoto EILSEQ, if an invalid multibyte sequence was encountered. It returns (size_t) -2if it couldn't parse a complete multibyte character, meaning that nshould be increased.
ATTRIBUTESFor an explanation of the terms used in this section, see attributes(7).
|mbrtowc()||Thread safety||MT-Unsafe race:mbrtowc/!ps|
CONFORMING TOPOSIX.1-2001, POSIX.1-2008, C99.
NOTESThe behavior of mbrtowc() depends on the LC_CTYPEcategory of the current locale.
SEE ALSOmbsinit(3), mbsrtowcs(3)
This document was created by man2html, using the manual pages.
Time: 22:27:54 GMT, June 20, 2016