1 .\" Copyright (c) Bruno Haible <haible@clisp.cons.org>
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.
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
16 .TH WCSTOMBS 3 2011-10-16 "GNU" "Linux Programmer's Manual"
18 wcstombs \- convert a wide-character string to a multibyte string
21 .B #include <stdlib.h>
23 .BI "size_t wcstombs(char *" dest ", const wchar_t *" src ", size_t " n );
26 If \fIdest\fP is not a NULL pointer, the
29 the wide-character string \fIsrc\fP to a multibyte string starting at
31 At most \fIn\fP bytes are written to \fIdest\fP.
33 starts in the initial state.
34 The conversion can stop for three reasons:
36 1. A wide character has been encountered that can not be represented as a
37 multibyte sequence (according to the current locale).
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.
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.
52 The programmer must ensure that there is room for at least \fIn\fP bytes
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.
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.
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
82 provides a thread safe interface to
83 the same functionality.