OSDN Git Service

(split) LDP: Update original to v3.37.
[linuxjm/LDP_man-pages.git] / original / man3 / wcrtomb.3
1 .\" Copyright (c) Bruno Haible <haible@clisp.cons.org>
2 .\"
3 .\" This is free documentation; you can redistribute it and/or
4 .\" modify it under the terms of the GNU General Public License as
5 .\" published by the Free Software Foundation; either version 2 of
6 .\" the License, or (at your option) any later version.
7 .\"
8 .\" References consulted:
9 .\"   GNU glibc-2 source code and manual
10 .\"   Dinkumware C library reference http://www.dinkumware.com/
11 .\"   OpenGroup's Single UNIX specification http://www.UNIX-systems.org/online.html
12 .\"   ISO/IEC 9899:1999
13 .\"
14 .TH WCRTOMB 3  2011-09-28 "GNU" "Linux Programmer's Manual"
15 .SH NAME
16 wcrtomb \- convert a wide character to a multibyte sequence
17 .SH SYNOPSIS
18 .nf
19 .B #include <wchar.h>
20 .sp
21 .BI "size_t wcrtomb(char *" s ", wchar_t " wc ", mbstate_t *" ps );
22 .fi
23 .SH DESCRIPTION
24 The main case for this function is when \fIs\fP is
25 not NULL and \fIwc\fP is not a null wide character (L\(aq\\0\(aq).
26 In this case, the
27 .BR wcrtomb ()
28 function
29 converts the wide character \fIwc\fP
30 to its multibyte representation and stores it
31 at the beginning of the character
32 array pointed to by \fIs\fP.
33 It updates the shift state \fI*ps\fP, and
34 returns the length of said multibyte representation,
35 that is, the number of bytes
36 written at \fIs\fP.
37 .PP
38 A different case is when \fIs\fP is not NULL,
39 but \fIwc\fP is a null wide character (L\(aq\\0\(aq).
40 In this
41 case the
42 .BR wcrtomb ()
43 function stores at
44 the character array pointed to by
45 \fIs\fP the shift sequence needed to
46 bring \fI*ps\fP back to the initial state,
47 followed by a \(aq\\0\(aq byte.
48 It updates the shift state \fI*ps\fP (i.e., brings
49 it into the initial state),
50 and returns the length of the shift sequence plus
51 one, that is, the number of bytes written at \fIs\fP.
52 .PP
53 A third case is when \fIs\fP is NULL.
54 In this case \fIwc\fP is ignored,
55 and the function effectively returns
56
57     wcrtomb(buf, L\(aq\\0\(aq, ps)
58
59 where
60 .I buf
61 is an internal anonymous buffer.
62 .PP
63 In all of the above cases, if \fIps\fP is a NULL pointer, a static anonymous
64 state only known to the
65 .BR wcrtomb ()
66 function is used instead.
67 .SH "RETURN VALUE"
68 The
69 .BR wcrtomb ()
70 function returns the number of
71 bytes that have been or would
72 have been written to the byte array at \fIs\fP.
73 If \fIwc\fP can not be
74 represented as a multibyte sequence (according to the current locale),
75 .I (size_t)\ \-1
76 is returned, and \fIerrno\fP set to \fBEILSEQ\fP.
77 .SH "CONFORMING TO"
78 C99.
79 .SH NOTES
80 The behavior of
81 .BR wcrtomb ()
82 depends on the
83 .B LC_CTYPE
84 category of the
85 current locale.
86 .PP
87 Passing NULL as \fIps\fP is not multithread safe.
88 .SH "SEE ALSO"
89 .BR wcsrtombs (3)