OSDN Git Service

(split) LDP: Update original to LDP v3.50.
[linuxjm/LDP_man-pages.git] / original / man3 / wcstombs.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 WCSTOMBS 3  2011-10-16 "GNU" "Linux Programmer's Manual"
17 .SH NAME
18 wcstombs \- convert a wide-character string to a multibyte string
19 .SH SYNOPSIS
20 .nf
21 .B #include <stdlib.h>
22 .sp
23 .BI "size_t wcstombs(char *" dest ", const wchar_t *" src ", size_t " n );
24 .fi
25 .SH DESCRIPTION
26 If \fIdest\fP is not a NULL pointer, the
27 .BR wcstombs ()
28 function converts
29 the wide-character string \fIsrc\fP to a multibyte string starting at
30 \fIdest\fP.
31 At most \fIn\fP bytes are written to \fIdest\fP.
32 The conversion
33 starts in the initial state.
34 The conversion can stop for three reasons:
35 .PP
36 1. A wide character has been encountered that can not be represented as a
37 multibyte sequence (according to the current locale).
38 In this case
39 .I (size_t)\ \-1
40 is returned.
41 .PP
42 2. The length limit forces a stop.
43 In this case the number of bytes written to
44 \fIdest\fP is returned, but the shift state at this point is lost.
45 .PP
46 3. The wide-character string has been completely converted, including the
47 terminating null wide character (L\(aq\\0\(aq).
48 In this case the conversion ends in the initial state.
49 The number of bytes written to \fIdest\fP,
50 excluding the terminating null byte (\(aq\\0\(aq), is returned.
51 .PP
52 The programmer must ensure that there is room for at least \fIn\fP bytes
53 at \fIdest\fP.
54 .PP
55 If \fIdest\fP is NULL, \fIn\fP is ignored, and the conversion proceeds as
56 above, except that the converted bytes are not written out to memory,
57 and that no length limit exists.
58 .PP
59 In order to avoid the case 2 above, the programmer should make sure \fIn\fP
60 is greater or equal to \fIwcstombs(NULL,src,0)+1\fP.
61 .SH RETURN VALUE
62 The
63 .BR wcstombs ()
64 function returns the number of bytes that make up the
65 converted part of multibyte sequence, not including the terminating null byte.
66 If a wide character was encountered which could not be
67 converted,
68 .I (size_t)\ \-1
69 is returned.
70 .SH CONFORMING TO
71 C99.
72 .SH NOTES
73 The behavior of
74 .BR wcstombs ()
75 depends on the
76 .B LC_CTYPE
77 category of the
78 current locale.
79 .PP
80 The function
81 .BR wcsrtombs (3)
82 provides a thread safe interface to
83 the same functionality.
84 .SH SEE ALSO
85 .BR mbstowcs (3),
86 .BR wcsrtombs (3)