2004-11-03 13:51:07 +00:00
|
|
|
.\" Copyright (c) Bruno Haible <haible@clisp.cons.org>
|
|
|
|
.\"
|
|
|
|
.\" This is free documentation; you can redistribute it and/or
|
|
|
|
.\" modify it under the terms of the GNU General Public License as
|
|
|
|
.\" published by the Free Software Foundation; either version 2 of
|
|
|
|
.\" the License, or (at your option) any later version.
|
|
|
|
.\"
|
|
|
|
.\" References consulted:
|
|
|
|
.\" GNU glibc-2 source code and manual
|
|
|
|
.\" Dinkumware C library reference http://www.dinkumware.com/
|
|
|
|
.\" OpenGroup's Single Unix specification http://www.UNIX-systems.org/online.html
|
|
|
|
.\" ISO/IEC 9899:1999
|
|
|
|
.\"
|
|
|
|
.TH WCSTOMBS 3 1999-07-25 "GNU" "Linux Programmer's Manual"
|
|
|
|
.SH NAME
|
2007-04-24 19:40:35 +00:00
|
|
|
wcstombs \- convert a wide-character string to a multibyte string
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH SYNOPSIS
|
|
|
|
.nf
|
|
|
|
.B #include <stdlib.h>
|
|
|
|
.sp
|
|
|
|
.BI "size_t wcstombs(char *" dest ", const wchar_t *" src ", size_t " n );
|
|
|
|
.fi
|
|
|
|
.SH DESCRIPTION
|
2007-05-12 09:06:04 +00:00
|
|
|
If \fIdest\fP is not a NULL pointer, the
|
|
|
|
.BR wcstombs ()
|
|
|
|
function converts
|
2004-11-03 13:51:07 +00:00
|
|
|
the wide-character string \fIsrc\fP to a multibyte string starting at
|
2007-04-12 22:42:49 +00:00
|
|
|
\fIdest\fP.
|
|
|
|
At most \fIn\fP bytes are written to \fIdest\fP.
|
|
|
|
The conversion
|
|
|
|
starts in the initial state.
|
|
|
|
The conversion can stop for three reasons:
|
2004-11-03 13:51:07 +00:00
|
|
|
.PP
|
|
|
|
1. A wide character has been encountered that can not be represented as a
|
2007-04-12 22:42:49 +00:00
|
|
|
multibyte sequence (according to the current locale).
|
|
|
|
In this case
|
2007-12-22 16:26:51 +00:00
|
|
|
.I (size_t)\ \-1
|
2007-07-09 21:33:55 +00:00
|
|
|
is returned.
|
2004-11-03 13:51:07 +00:00
|
|
|
.PP
|
2007-04-12 22:42:49 +00:00
|
|
|
2. The length limit forces a stop.
|
|
|
|
In this case the number of bytes written to
|
2004-11-03 13:51:07 +00:00
|
|
|
\fIdest\fP is returned, but the shift state at this point is lost.
|
|
|
|
.PP
|
|
|
|
3. The wide-character string has been completely converted, including the
|
2008-06-09 15:49:35 +00:00
|
|
|
terminating L\(aq\\0\(aq.
|
2007-04-12 22:42:49 +00:00
|
|
|
In this case the conversion ends in the initial state.
|
2008-06-09 15:49:35 +00:00
|
|
|
The number of bytes written to \fIdest\fP,
|
|
|
|
excluding the terminating \(aq\\0\(aq byte, is returned.
|
2004-11-03 13:51:07 +00:00
|
|
|
.PP
|
|
|
|
The programmer must ensure that there is room for at least \fIn\fP bytes
|
|
|
|
at \fIdest\fP.
|
|
|
|
.PP
|
|
|
|
If \fIdest\fP is NULL, \fIn\fP is ignored, and the conversion proceeds as
|
2007-05-12 00:30:29 +00:00
|
|
|
above, except that the converted bytes are not written out to memory,
|
|
|
|
and that no length limit exists.
|
2004-11-03 13:51:07 +00:00
|
|
|
.PP
|
|
|
|
In order to avoid the case 2 above, the programmer should make sure \fIn\fP
|
|
|
|
is greater or equal to \fIwcstombs(NULL,src,0)+1\fP.
|
|
|
|
.SH "RETURN VALUE"
|
2007-05-12 09:06:04 +00:00
|
|
|
The
|
|
|
|
.BR wcstombs ()
|
|
|
|
function returns the number of bytes that make up the
|
2004-11-03 13:51:07 +00:00
|
|
|
converted part of multibyte sequence, not including the terminating null byte.
|
2007-05-12 00:30:29 +00:00
|
|
|
If a wide character was encountered which could not be
|
2007-07-09 21:33:55 +00:00
|
|
|
converted,
|
2007-12-22 16:26:51 +00:00
|
|
|
.I (size_t)\ \-1
|
2007-07-09 21:33:55 +00:00
|
|
|
is returned.
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH "CONFORMING TO"
|
2006-08-03 13:57:30 +00:00
|
|
|
C99.
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH NOTES
|
2007-06-08 09:56:56 +00:00
|
|
|
The behavior of
|
2007-05-12 09:06:04 +00:00
|
|
|
.BR wcstombs ()
|
2007-06-22 18:25:23 +00:00
|
|
|
depends on the
|
|
|
|
.B LC_CTYPE
|
|
|
|
category of the
|
2004-11-03 13:51:07 +00:00
|
|
|
current locale.
|
|
|
|
.PP
|
2007-05-12 09:06:04 +00:00
|
|
|
The function
|
|
|
|
.BR wcsrtombs (3)
|
|
|
|
provides a thread safe interface to
|
2007-05-12 01:02:19 +00:00
|
|
|
the same functionality.
|
2007-05-16 18:25:50 +00:00
|
|
|
.SH "SEE ALSO"
|
|
|
|
.BR wcsrtombs (3)
|