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
|
|
|
|
.\"
|
2010-09-15 06:01:17 +00:00
|
|
|
.TH WCSNRTOMBS 3 2010-09-15 "GNU" "Linux Programmer's Manual"
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH NAME
|
2007-04-24 19:40:35 +00:00
|
|
|
wcsnrtombs \- convert a wide-character string to a multibyte string
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH SYNOPSIS
|
|
|
|
.nf
|
|
|
|
.B #include <wchar.h>
|
|
|
|
.sp
|
|
|
|
.BI "size_t wcsnrtombs(char *" dest ", const wchar_t **" src ", size_t " nwc ,
|
2007-04-03 15:32:52 +00:00
|
|
|
.BI " size_t " len ", mbstate_t *" ps );
|
2004-11-03 13:51:07 +00:00
|
|
|
.fi
|
2010-09-15 06:01:17 +00:00
|
|
|
.sp
|
|
|
|
.in -4n
|
|
|
|
Feature Test Macro Requirements for glibc (see
|
|
|
|
.BR feature_test_macros (7)):
|
|
|
|
.in
|
|
|
|
.sp
|
|
|
|
.BR wcsnrtombs ():
|
faccessat.2, dprintf.3, fexecve.3, fmemopen.3, mbsnrtowcs.3, mkfifoat.3, opendir.3, stpcpy.3, stpncpy.3, strnlen.3, strsignal.3, wcpcpy.3, wcpncpy.3, wcscasecmp.3, wcsdup.3, wcsncasecmp.3, wcsnlen.3, wcsnrtombs.3: ffix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-09-19 16:57:10 +00:00
|
|
|
.PD 0
|
|
|
|
.ad l
|
|
|
|
.RS 4
|
|
|
|
.TP 4
|
|
|
|
Since glibc 2.10:
|
|
|
|
_XOPEN_SOURCE\ >=\ 700 || _POSIX_C_SOURCE\ >=\ 200809L
|
|
|
|
.TP
|
2010-09-15 06:01:17 +00:00
|
|
|
Before glibc 2.10:
|
|
|
|
_GNU_SOURCE
|
faccessat.2, dprintf.3, fexecve.3, fmemopen.3, mbsnrtowcs.3, mkfifoat.3, opendir.3, stpcpy.3, stpncpy.3, strnlen.3, strsignal.3, wcpcpy.3, wcpncpy.3, wcscasecmp.3, wcsdup.3, wcsncasecmp.3, wcsnlen.3, wcsnrtombs.3: ffix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-09-19 16:57:10 +00:00
|
|
|
.RE
|
|
|
|
.ad
|
|
|
|
.PD
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH DESCRIPTION
|
2007-05-12 09:06:04 +00:00
|
|
|
The
|
|
|
|
.BR wcsnrtombs ()
|
|
|
|
function is like the
|
2007-06-14 06:25:37 +00:00
|
|
|
.BR wcsrtombs (3)
|
2007-05-12 09:06:04 +00:00
|
|
|
function,
|
2007-04-12 22:42:49 +00:00
|
|
|
except that the number of wide characters to be converted,
|
2006-12-27 03:54:41 +00:00
|
|
|
starting at \fI*src\fP, is limited to \fInwc\fP.
|
2004-11-03 13:51:07 +00:00
|
|
|
.PP
|
2007-04-12 22:42:49 +00:00
|
|
|
If \fIdest\fP is not a NULL pointer,
|
2007-05-12 09:06:04 +00:00
|
|
|
the
|
|
|
|
.BR wcsnrtombs ()
|
|
|
|
function converts
|
2004-11-03 13:51:07 +00:00
|
|
|
at most \fInwc\fP wide characters from
|
|
|
|
the wide-character string \fI*src\fP to a multibyte string starting at
|
2007-04-12 22:42:49 +00:00
|
|
|
\fIdest\fP.
|
|
|
|
At most \fIlen\fP bytes are written to \fIdest\fP.
|
|
|
|
The shift state
|
|
|
|
\fI*ps\fP is updated.
|
|
|
|
The conversion is effectively performed by repeatedly
|
2007-07-18 20:11:21 +00:00
|
|
|
calling
|
2007-09-18 18:48:39 +00:00
|
|
|
.IR "wcrtomb(dest, *src, ps)" ,
|
2007-04-12 22:42:49 +00:00
|
|
|
as long as this call succeeds,
|
|
|
|
and then incrementing \fIdest\fP by the
|
|
|
|
number of bytes written and \fI*src\fP
|
|
|
|
by one.
|
|
|
|
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 \fI*src\fP
|
2007-07-09 21:33:55 +00:00
|
|
|
is left pointing to the invalid wide character,
|
2007-12-22 16:26:51 +00:00
|
|
|
.I (size_t)\ \-1
|
2007-07-09 21:33:55 +00:00
|
|
|
is returned,
|
2006-02-09 20:29:51 +00:00
|
|
|
and \fIerrno\fP is set to \fBEILSEQ\fP.
|
2004-11-03 13:51:07 +00:00
|
|
|
.PP
|
2007-04-12 22:42:49 +00:00
|
|
|
2. \fInwc\fP wide characters have been
|
2008-06-09 15:49:35 +00:00
|
|
|
converted without encountering a L\(aq\\0\(aq,
|
2007-04-12 22:42:49 +00:00
|
|
|
or the length limit forces a stop.
|
|
|
|
In this case \fI*src\fP is left pointing
|
2004-11-03 13:51:07 +00:00
|
|
|
to the next wide character to be converted, and the number of bytes written
|
|
|
|
to \fIdest\fP is returned.
|
|
|
|
.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 (which has the side effect of bringing back \fI*ps\fP
|
2007-04-12 22:42:49 +00:00
|
|
|
to the initial state).
|
|
|
|
In this case \fI*src\fP is set to NULL, and the number
|
2008-06-09 15:49:35 +00:00
|
|
|
of bytes written to \fIdest\fP, excluding the terminating \(aq\\0\(aq byte, is
|
2004-11-03 13:51:07 +00:00
|
|
|
returned.
|
|
|
|
.PP
|
2007-04-12 22:42:49 +00:00
|
|
|
If \fIdest\fP is NULL, \fIlen\fP is ignored,
|
|
|
|
and the conversion proceeds as above,
|
|
|
|
except that the converted bytes are not written out to memory, and that
|
2004-11-03 13:51:07 +00:00
|
|
|
no destination length limit exists.
|
|
|
|
.PP
|
2007-04-12 22:42:49 +00:00
|
|
|
In both of the above cases,
|
|
|
|
if \fIps\fP is a NULL pointer, a static anonymous
|
2004-11-03 13:51:07 +00:00
|
|
|
state only known to the wcsnrtombs function is used instead.
|
|
|
|
.PP
|
|
|
|
The programmer must ensure that there is room for at least \fIlen\fP bytes
|
|
|
|
at \fIdest\fP.
|
|
|
|
.SH "RETURN VALUE"
|
2007-05-12 09:06:04 +00:00
|
|
|
The
|
|
|
|
.BR wcsnrtombs ()
|
|
|
|
function returns
|
2007-04-12 22:42:49 +00:00
|
|
|
the number of bytes that make up the
|
|
|
|
converted part of multibyte sequence,
|
|
|
|
not including the terminating null byte.
|
|
|
|
If a wide character was encountered which
|
2007-07-09 21:33:55 +00:00
|
|
|
could not be converted,
|
2007-12-22 16:26:51 +00:00
|
|
|
.I (size_t)\ \-1
|
2006-02-09 20:29:51 +00:00
|
|
|
is returned, and \fIerrno\fP set to \fBEILSEQ\fP.
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH "CONFORMING TO"
|
|
|
|
This function is a GNU extension.
|
|
|
|
.SH NOTES
|
2007-06-08 09:56:56 +00:00
|
|
|
The behavior of
|
2007-05-12 09:06:04 +00:00
|
|
|
.BR wcsnrtombs ()
|
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
|
2008-11-19 19:31:54 +00:00
|
|
|
Passing NULL as \fIps\fP is not multithread safe.
|
2007-05-16 18:25:50 +00:00
|
|
|
.SH "SEE ALSO"
|
|
|
|
.BR iconv (3),
|
|
|
|
.BR wcsrtombs (3)
|