1 .\" Copyright (c) Bruno Haible <haible@clisp.cons.org>
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.
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
14 .TH WCSTOMBS 3 1999-07-25 "GNU" "Linux Programmer's Manual"
16 wcstombs \- convert a wide-character string to a multibyte string
19 .B #include <stdlib.h>
21 .BI "size_t wcstombs(char *" dest ", const wchar_t *" src ", size_t " n );
24 If \fIdest\fP is not a NULL pointer, the
27 the wide-character string \fIsrc\fP to a multibyte string starting at
29 At most \fIn\fP bytes are written to \fIdest\fP.
31 starts in the initial state.
32 The conversion can stop for three reasons:
34 1. A wide character has been encountered that can not be represented as a
35 multibyte sequence (according to the current locale).
40 2. The length limit forces a stop.
41 In this case the number of bytes written to
42 \fIdest\fP is returned, but the shift state at this point is lost.
44 3. The wide-character string has been completely converted, including the
45 terminating L\(aq\\0\(aq.
46 In this case the conversion ends in the initial state.
47 The number of bytes written to \fIdest\fP,
48 excluding the terminating \(aq\\0\(aq byte, is returned.
50 The programmer must ensure that there is room for at least \fIn\fP bytes
53 If \fIdest\fP is NULL, \fIn\fP is ignored, and the conversion proceeds as
54 above, except that the converted bytes are not written out to memory,
55 and that no length limit exists.
57 In order to avoid the case 2 above, the programmer should make sure \fIn\fP
58 is greater or equal to \fIwcstombs(NULL,src,0)+1\fP.
62 function returns the number of bytes that make up the
63 converted part of multibyte sequence, not including the terminating null byte.
64 If a wide character was encountered which could not be
80 provides a thread safe interface to
81 the same functionality.