1mbtowc(3C) Standard C Library Functions mbtowc(3C)
2
3
4
6 mbtowc - convert a character to a wide-character code
7
9 #include <stdlib.h>
10
11 int mbtowc(wchar_t *restrict pwc, const char *restrict s, size_t n);
12
13
15 If s is not a null pointer, mbtowc() determines the number of the bytes
16 that constitute the character pointed to by s. It then determines the
17 wide-character code for the value of type wchar_t that corresponds to
18 that character. (The value of the wide-character code corresponding to
19 the null byte is 0.) If the character is valid and pwc is not a null
20 pointer, mbtowc() stores the wide-character code in the object pointed
21 to by pwc.
22
23
24 A call with s as a null pointer causes this function to return 0. The
25 behavior of this function is affected by the LC_CTYPE category of the
26 current locale. At most n bytes of the array pointed to by s will be
27 examined.
28
30 If s is a null pointer, mbtowc() returns 0. If s is not a null pointer,
31 mbtowc() returns 0 (if s points to the null byte), the number of bytes
32 that constitute the converted character (if the next n or fewer bytes
33 form a valid character), or −1 and may set errno to indicate the error
34 (if they do not form a valid character).
35
36
37 In no case will the value returned be greater than n or the value of
38 the MB_CUR_MAX macro.
39
41 The mbtowc() function may fail if:
42
43 EILSEQ Invalid character sequence is detected.
44
45
47 The mbtowc() function can be used safely in multithreaded applications,
48 as long as setlocale(3C) is not being called to change the locale.
49
51 See attributes(5) for descriptions of the following attributes:
52
53
54
55
56 ┌─────────────────────────────┬─────────────────────────────┐
57 │ATTRIBUTE TYPE │ATTRIBUTE VALUE │
58 ├─────────────────────────────┼─────────────────────────────┤
59 │CSI │Enabled │
60 ├─────────────────────────────┼─────────────────────────────┤
61 │Interface Stability │Standard │
62 ├─────────────────────────────┼─────────────────────────────┤
63 │MT-Level │MT-Safe with exceptions │
64 └─────────────────────────────┴─────────────────────────────┘
65
67 mblen(3C), mbstowcs(3C), setlocale(3C), wcstombs(3C), wctomb(3C),
68 attributes(5), standards(5)
69
70
71
72SunOS 5.11 1 Nov 2003 mbtowc(3C)