summaryrefslogtreecommitdiff
path: root/man3p/mbtowc.3p
blob: e32de36ecec33bafaa9b201fa5349e73534e53fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved 
.TH "MBTOWC" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" mbtowc 
.SH NAME
mbtowc \- convert a character to a wide-character code
.SH SYNOPSIS
.LP
\fB#include <stdlib.h>
.br
.sp
int mbtowc(wchar_t *restrict\fP \fIpwc\fP\fB, const char *restrict\fP
\fIs\fP\fB, size_t\fP \fIn\fP\fB);
.br
\fP
.SH DESCRIPTION
.LP
If \fIs\fP is not a null pointer, \fImbtowc\fP() shall determine the
number of bytes that constitute the character pointed to
by \fIs\fP. It shall then determine the wide-character code for the
value of type \fBwchar_t\fP that corresponds to that
character. (The value of the wide-character code corresponding to
the null byte is 0.) If the character is valid and \fIpwc\fP is
not a null pointer, \fImbtowc\fP() shall store the wide-character
code in the object pointed to by \fIpwc\fP.
.LP
The behavior of this function is affected by the \fILC_CTYPE\fP category
of the current locale. For a state-dependent encoding,
this function is placed into its initial state by a call for which
its character pointer argument, \fIs\fP, is a null pointer.
Subsequent calls with \fIs\fP as other than a null pointer shall cause
the internal state of the function to be altered as
necessary. A call with \fIs\fP as a null pointer shall cause this
function to return a non-zero value if encodings have state
dependency, and 0 otherwise. If the implementation employs special
bytes to change the shift state, these bytes shall not produce
separate wide-character codes, but shall be grouped with an adjacent
character. Changing the \fILC_CTYPE\fP category causes the
shift state of this function to be unspecified. At most \fIn\fP bytes
of the array pointed to by \fIs\fP shall be examined.
.LP
The implementation shall behave as if no function defined in this
volume of IEEE\ Std\ 1003.1-2001 calls
\fImbtowc\fP().
.SH RETURN VALUE
.LP
If \fIs\fP is a null pointer, \fImbtowc\fP() shall return a non-zero
or 0 value, if character encodings, respectively, do or
do not have state-dependent encodings. If \fIs\fP is not a null pointer,
\fImbtowc\fP() shall either return 0 (if \fIs\fP points
to the null byte), or return the number of bytes that constitute the
converted character (if the next \fIn\fP or fewer bytes form
a valid character), or return -1   \ and may set \fIerrno\fP to indicate
the error  (if they do not form a valid character).
.LP
In no case shall the value returned be greater than \fIn\fP or the
value of the {MB_CUR_MAX} macro.
.SH ERRORS
.LP
The \fImbtowc\fP() function may fail if:
.TP 7
.B EILSEQ
Invalid character sequence is detected. 
.sp
.LP
\fIThe following sections are informative.\fP
.SH EXAMPLES
.LP
None.
.SH APPLICATION USAGE
.LP
None.
.SH RATIONALE
.LP
None.
.SH FUTURE DIRECTIONS
.LP
None.
.SH SEE ALSO
.LP
\fImblen\fP() , \fImbstowcs\fP() , \fIwctomb\fP() , \fIwcstombs\fP()
, the Base Definitions volume of
IEEE\ Std\ 1003.1-2001, \fI<stdlib.h>\fP
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the
event of any discrepancy between this version and the original IEEE and
The Open Group Standard, the original IEEE and The Open Group Standard
is the referee document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html .