OSDN Git Service

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