OSDN Git Service

(split) Import translated manuals from JM CVS Repository.
[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  1999-07-25 "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
26 L\(aq\\0\(aq.
27 In this case, the
28 .BR wcrtomb ()
29 function
30 converts the wide character \fIwc\fP
31 to its multibyte representation and stores it
32 at the beginning of the character
33 array pointed to by \fIs\fP.
34 It updates the shift state \fI*ps\fP, and
35 returns the length of said multibyte representation,
36 that is, the number of bytes
37 written at \fIs\fP.
38 .PP
39 A different case is when \fIs\fP is not NULL but \fIwc\fP is 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 wcrtomb(buf,L\(aq\\0\(aq,\fIps\fP) where
56 buf is an internal anonymous buffer.
57 .PP
58 In all of the above cases, if \fIps\fP is a NULL pointer, a static anonymous
59 state only known to the
60 .BR wcrtomb ()
61 function is used instead.
62 .SH "RETURN VALUE"
63 The
64 .BR wcrtomb ()
65 function returns the number of
66 bytes that have been or would
67 have been written to the byte array at \fIs\fP.
68 If \fIwc\fP can not be
69 represented as a multibyte sequence (according to the current locale),
70 .I (size_t)\ \-1
71 is returned, and \fIerrno\fP set to \fBEILSEQ\fP.
72 .SH "CONFORMING TO"
73 C99.
74 .SH NOTES
75 The behavior of
76 .BR wcrtomb ()
77 depends on the
78 .B LC_CTYPE
79 category of the
80 current locale.
81 .PP
82 Passing NULL as \fIps\fP is not multithread safe.
83 .SH "SEE ALSO"
84 .BR wcsrtombs (3)