mbtowc.3 (1548B)
1 .TH MBTOWC 3 2 .SH NAME 3 mbtowc - converts from multibyte encoding to wchar_t 4 .SH SYNOPSIS 5 #include <stdlib.h> 6 7 int mbtowc(wchar_t * restrict pwc, const char * restrict s, size_t n) 8 .SH DESCRIPTION 9 if 10 .I s 11 is not a null pointer, 12 the 13 .BR mbtowc () 14 function inspects at most 15 .I n 16 bytes beginning with the byte pointed to by 17 .I s 18 to determine the number of bytes needed 19 to complete the next multibyte character 20 (including any shift sequences). 21 If the function determines 22 that the next multibyte character is complete and valid, 23 it determines the value of the corresponding wide character 24 and then, 25 if 26 .I pwc 27 is not a null pointer, 28 stores that value in the object pointed to by 29 .IR pwc . 30 If the corresponding wide character is the null wide character, 31 the function is left in the initial conversion state. 32 .SH RETURN VALUE 33 If 34 .I s 35 is a null pointer, 36 the 37 .BR mbtowc () 38 function returns a nonzero or zero value, 39 if multibyte character encodings, 40 respectively, 41 do or do not have state-dependent encodings. 42 If 43 .I s 44 is not a null pointer, 45 the 46 .BR mbtowc () 47 function either returns 0 48 (if 49 .I s 50 points to the null character), 51 or returns the number of bytes 52 that are contained in the converted multibyte character 53 (if the next 54 .I n 55 or fewer bytes form a valid multibyte character), 56 or returns -1 57 (if they do not form a valid multibyte character). 58 .PP 59 In no case will the value returned be 60 greater than 61 .I n 62 or the value of the 63 .I MB_CUR_MAX 64 macro. 65 .SH STANDARDS 66 ISO/IEC 9899:1999 Section 7.20.7.2 Paragraph 1,2,3,4,5 67 .SH SEE ALSO 68 .BR stdlib.h (3) 69 .BR wchar.h (3)