1 '\" te
   2 .\" Copyright (c) 1992, X/Open Company Limited. All Rights Reserved.  Portions Copyright (c) 2003, Sun Microsystems, Inc.  All Rights Reserved.
   3 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
   4 .\" http://www.opengroup.org/bookstore/.
   5 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
   6 .\"  This notice shall appear on any product containing this material.
   7 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
   8 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
   9 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
  10 .TH MBSRTOWCS 3C "Nov 1, 2003"
  11 .SH NAME
  12 mbsrtowcs \- convert a character string to a wide-character string
  13 (restartable)
  14 .SH SYNOPSIS
  15 .LP
  16 .nf
  17 #include <wchar.h>
  18 
  19 \fBsize_t\fR \fBmbsrtowcs\fR(\fBwchar_t *restrict\fR \fIdst\fR, \fBconst char **restrict\fR \fIsrc\fR,
  20      \fBsize_t\fR \fIlen\fR, \fBmbstate_t *restrict\fR \fIps\fR);
  21 .fi
  22 
  23 .SH DESCRIPTION
  24 .sp
  25 .LP
  26 The \fBmbsrtowcs()\fR function converts a sequence of characters, beginning in
  27 the conversion state described by the object pointed to by \fIps\fR, from the
  28 array indirectly pointed to by \fIsrc\fR into a sequence of corresponding
  29 wide-characters. If \fIdst\fR is not a null pointer, the converted characters
  30 are stored into the array pointed to by  \fIdst\fR. Conversion continues up to
  31 and including a terminating null character, which is also stored.  Conversion
  32 stops early in either of the following cases:
  33 .RS +4
  34 .TP
  35 .ie t \(bu
  36 .el o
  37 When a sequence of bytes is encountered that does not form a valid character.
  38 .RE
  39 .RS +4
  40 .TP
  41 .ie t \(bu
  42 .el o
  43 When \fIlen\fR codes have been stored into the array pointed to by \fIdst\fR
  44 (and  \fIdst\fR is not a null pointer).
  45 .RE
  46 .sp
  47 .LP
  48 Each conversion takes place as if by a call to the \fBmbrtowc()\fR function.
  49 .sp
  50 .LP
  51 If \fIdst\fR is not a null pointer, the pointer object pointed to by \fIsrc\fR
  52 is assigned either a null pointer (if conversion stopped due to reaching a
  53 terminating null character) or the address just past the last character
  54 converted (if any).  If conversion stopped due to reaching a terminating null
  55 character, and if \fIdst\fR is not a null pointer, the resulting state
  56 described is the initial conversion state.
  57 .sp
  58 .LP
  59 If \fIps\fR is a null pointer, the \fBmbsrtowcs()\fR function uses its own
  60 internal \fBmbstate_t\fR object, which is initialized at program startup to the
  61 initial conversion state.  Otherwise, the  \fBmbstate_t\fR object pointed to by
  62 \fIps\fR is used to completely describe the current conversion state of the
  63 associated character sequence. Solaris will behave as if no function defined in
  64 the Solaris Reference Manual calls \fBmbsrtowcs()\fR.
  65 .sp
  66 .LP
  67 The behavior of this function is affected by the \fBLC_CTYPE\fR category of the
  68 current locale.  See \fBenviron\fR(5).
  69 .SH RETURN VALUES
  70 .sp
  71 .LP
  72 If the input conversion encounters a sequence of bytes that do not form a valid
  73 character, an encoding error occurs.  In this case, the \fBmbsrtowcs()\fR
  74 function stores the value of the macro \fBEILSEQ\fR in \fBerrno\fR and returns
  75 \fB(size_t)\(mi1\fR; the conversion state is undefined.  Otherwise, it returns
  76 the number of characters successfully converted, not including the terminating
  77 null (if any).
  78 .SH ERRORS
  79 .sp
  80 .LP
  81 The \fBmbsrtowcs()\fR function may fail if:
  82 .sp
  83 .ne 2
  84 .na
  85 \fB\fBEINVAL\fR\fR
  86 .ad
  87 .RS 10n
  88 The \fIps\fR argument points to an object that contains an invalid conversion
  89 state.
  90 .RE
  91 
  92 .sp
  93 .ne 2
  94 .na
  95 \fB\fBEILSEQ\fR\fR
  96 .ad
  97 .RS 10n
  98 Invalid character sequence is detected.
  99 .RE
 100 
 101 .SH ATTRIBUTES
 102 .sp
 103 .LP
 104 See \fBattributes\fR(5) for descriptions of the following attributes:
 105 .sp
 106 
 107 .sp
 108 .TS
 109 box;
 110 c | c
 111 l | l .
 112 ATTRIBUTE TYPE  ATTRIBUTE VALUE
 113 _
 114 Interface Stability     Standard
 115 _
 116 MT-Level        See NOTES below
 117 .TE
 118 
 119 .SH SEE ALSO
 120 .sp
 121 .LP
 122 \fBmbrtowc\fR(3C), \fBmbsinit\fR(3C), \fBsetlocale\fR(3C), \fBattributes\fR(5),
 123 \fBenviron\fR(5), \fBstandards\fR(5)
 124 .SH NOTES
 125 .sp
 126 .LP
 127 If \fIps\fR is not a null pointer, \fBmbsrtowcs()\fR uses the \fBmbstate_t\fR
 128 object pointed to by \fIps\fR and the function can be used safely in
 129 multithreaded applications, as long as \fBsetlocale\fR(3C) is not being called
 130 to change the locale. If \fIps\fR is a null pointer, \fBmbsrtowcs()\fR uses its
 131 internal \fBmbstate_t\fR object and the function is Unsafe in multithreaded
 132 applications.