10d5acd74SJohn Marino.\" Copyright (c) 2002-2004 Tim J. Robbins 2eee2ef09SJoerg Sonnenberger.\" All rights reserved. 3eee2ef09SJoerg Sonnenberger.\" 4eee2ef09SJoerg Sonnenberger.\" Redistribution and use in source and binary forms, with or without 5eee2ef09SJoerg Sonnenberger.\" modification, are permitted provided that the following conditions 6eee2ef09SJoerg Sonnenberger.\" are met: 7eee2ef09SJoerg Sonnenberger.\" 1. Redistributions of source code must retain the above copyright 8eee2ef09SJoerg Sonnenberger.\" notice, this list of conditions and the following disclaimer. 9eee2ef09SJoerg Sonnenberger.\" 2. Redistributions in binary form must reproduce the above copyright 10eee2ef09SJoerg Sonnenberger.\" notice, this list of conditions and the following disclaimer in the 11eee2ef09SJoerg Sonnenberger.\" documentation and/or other materials provided with the distribution. 12eee2ef09SJoerg Sonnenberger.\" 13eee2ef09SJoerg Sonnenberger.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14eee2ef09SJoerg Sonnenberger.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15eee2ef09SJoerg Sonnenberger.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16eee2ef09SJoerg Sonnenberger.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17eee2ef09SJoerg Sonnenberger.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18eee2ef09SJoerg Sonnenberger.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19eee2ef09SJoerg Sonnenberger.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20eee2ef09SJoerg Sonnenberger.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21eee2ef09SJoerg Sonnenberger.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22eee2ef09SJoerg Sonnenberger.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23eee2ef09SJoerg Sonnenberger.\" SUCH DAMAGE. 24eee2ef09SJoerg Sonnenberger.\" 250d5acd74SJohn Marino.\" $FreeBSD: head/lib/libc/locale/wcsrtombs.3 132497 2004-07-21 10:54:57Z tjr $ 260d5acd74SJohn Marino.\" 27*5b25d67aSSascha Wildner.Dd December 26, 2013 28eee2ef09SJoerg Sonnenberger.Dt WCSRTOMBS 3 29eee2ef09SJoerg Sonnenberger.Os 30eee2ef09SJoerg Sonnenberger.Sh NAME 310d5acd74SJohn Marino.Nm wcsrtombs , 32*5b25d67aSSascha Wildner.Nm wcsrtombs_l , 33*5b25d67aSSascha Wildner.Nm wcsnrtombs , 34*5b25d67aSSascha Wildner.Nm wcsnrtombs_l 350d5acd74SJohn Marino.Nd "convert a wide-character string to a character string (restartable)" 36eee2ef09SJoerg Sonnenberger.Sh LIBRARY 37eee2ef09SJoerg Sonnenberger.Lb libc 38eee2ef09SJoerg Sonnenberger.Sh SYNOPSIS 390d5acd74SJohn Marino.In wchar.h 40eee2ef09SJoerg Sonnenberger.Ft size_t 410d5acd74SJohn Marino.Fo wcsrtombs 420d5acd74SJohn Marino.Fa "char * restrict dst" "const wchar_t ** restrict src" 430d5acd74SJohn Marino.Fa "size_t len" "mbstate_t * restrict ps" 440d5acd74SJohn Marino.Fc 450d5acd74SJohn Marino.Ft size_t 460d5acd74SJohn Marino.Fo wcsnrtombs 470d5acd74SJohn Marino.Fa "char * restrict dst" "const wchar_t ** restrict src" "size_t nwc" 480d5acd74SJohn Marino.Fa "size_t len" "mbstate_t * restrict ps" 490d5acd74SJohn Marino.Fc 50*5b25d67aSSascha Wildner.In xlocale.h 51*5b25d67aSSascha Wildner.Ft size_t 52*5b25d67aSSascha Wildner.Fo wcsrtombs_l 53*5b25d67aSSascha Wildner.Fa "char * restrict dst" "const wchar_t ** restrict src" 54*5b25d67aSSascha Wildner.Fa "size_t len" "mbstate_t * restrict ps" "locale_t locale" 55*5b25d67aSSascha Wildner.Fc 56*5b25d67aSSascha Wildner.Ft size_t 57*5b25d67aSSascha Wildner.Fo wcsnrtombs_l 58*5b25d67aSSascha Wildner.Fa "char * restrict dst" "const wchar_t ** restrict src" "size_t nwc" 59*5b25d67aSSascha Wildner.Fa "size_t len" "mbstate_t * restrict ps" "locale_t locale" 60*5b25d67aSSascha Wildner.Fc 61eee2ef09SJoerg Sonnenberger.Sh DESCRIPTION 62eee2ef09SJoerg SonnenbergerThe 63eee2ef09SJoerg Sonnenberger.Fn wcsrtombs 64*5b25d67aSSascha Wildnerand 65*5b25d67aSSascha Wildner.Fn wcsrtombs_l 66*5b25d67aSSascha Wildnerfunctions convert a string of wide characters indirectly pointed to by 670d5acd74SJohn Marino.Fa src 680d5acd74SJohn Marinoto a corresponding multibyte character string stored in the array 690d5acd74SJohn Marinopointed to by 700d5acd74SJohn Marino.Fa dst . 710d5acd74SJohn MarinoNo more than 720d5acd74SJohn Marino.Fa len 730d5acd74SJohn Marinobytes are written to 740d5acd74SJohn Marino.Fa dst . 75eee2ef09SJoerg Sonnenberger.Pp 76eee2ef09SJoerg SonnenbergerIf 770d5acd74SJohn Marino.Fa dst 780d5acd74SJohn Marinois 790d5acd74SJohn Marino.Dv NULL , 800d5acd74SJohn Marinono characters are stored. 81eee2ef09SJoerg Sonnenberger.Pp 820d5acd74SJohn MarinoIf 830d5acd74SJohn Marino.Fa dst 840d5acd74SJohn Marinois not 850d5acd74SJohn Marino.Dv NULL , 860d5acd74SJohn Marinothe pointer pointed to by 870d5acd74SJohn Marino.Fa src 880d5acd74SJohn Marinois updated to point to the character after the one that conversion stopped at. 890d5acd74SJohn MarinoIf conversion stops because a null character is encountered, 900d5acd74SJohn Marino.Fa *src 910d5acd74SJohn Marinois set to 920d5acd74SJohn Marino.Dv NULL . 93eee2ef09SJoerg Sonnenberger.Pp 940d5acd74SJohn MarinoThe 950d5acd74SJohn Marino.Vt mbstate_t 960d5acd74SJohn Marinoargument, 970d5acd74SJohn Marino.Fa ps , 980d5acd74SJohn Marinois used to keep track of the shift state. 990d5acd74SJohn MarinoIf it is 1000d5acd74SJohn Marino.Dv NULL , 101eee2ef09SJoerg Sonnenberger.Fn wcsrtombs 102*5b25d67aSSascha Wildnerand 103*5b25d67aSSascha Wildner.Fn wcsrtombs_l 104*5b25d67aSSascha Wildneruse an internal, static 1050d5acd74SJohn Marino.Vt mbstate_t 1060d5acd74SJohn Marinoobject, which is initialized to the initial conversion state 1070d5acd74SJohn Marinoat program startup. 108eee2ef09SJoerg Sonnenberger.Pp 1090d5acd74SJohn MarinoThe 1100d5acd74SJohn Marino.Fn wcsnrtombs 111*5b25d67aSSascha Wildnerand 112*5b25d67aSSascha Wildner.Fn wcsnrtombs_l 113*5b25d67aSSascha Wildnerfunctions behave identically to 114*5b25d67aSSascha Wildner.Fn wcsrtombs 115*5b25d67aSSascha Wildnerand 116*5b25d67aSSascha Wildner.Fn wcsrtombs_l , 1170d5acd74SJohn Marinoexcept that conversion stops after reading at most 1180d5acd74SJohn Marino.Fa nwc 1190d5acd74SJohn Marinocharacters from the buffer pointed to by 1200d5acd74SJohn Marino.Fa src . 121*5b25d67aSSascha Wildner.Pp 122eee2ef09SJoerg SonnenbergerThe 123*5b25d67aSSascha Wildner.Fn wcsrtombs_l 124*5b25d67aSSascha Wildnerand 125*5b25d67aSSascha Wildner.Fn wcsnrtombs_l 126*5b25d67aSSascha Wildnerfunctions take an explicit 127*5b25d67aSSascha Wildner.Fa locale 128*5b25d67aSSascha Wildnerargument, whereas the 129eee2ef09SJoerg Sonnenberger.Fn wcsrtombs 1300d5acd74SJohn Marinoand 1310d5acd74SJohn Marino.Fn wcsnrtombs 132*5b25d67aSSascha Wildnerfunctions use the current global or per-thread locale. 133*5b25d67aSSascha Wildner.Sh RETURN VALUES 134*5b25d67aSSascha WildnerThe 135*5b25d67aSSascha Wildner.Fn wcsrtombs , 136*5b25d67aSSascha Wildner.Fn wcsrtombs_l , 137*5b25d67aSSascha Wildner.Fn wcsnrtombs , 138*5b25d67aSSascha Wildnerand 139*5b25d67aSSascha Wildner.Fn wcsnrtombs_l 1400d5acd74SJohn Marinofunctions return the number of bytes stored in 1410d5acd74SJohn Marinothe array pointed to by 1420d5acd74SJohn Marino.Fa dst 143*5b25d67aSSascha Wildner(not including any terminating null), if successful, otherwise they return 1440d5acd74SJohn Marino.Po Vt size_t Pc Ns \-1 . 145eee2ef09SJoerg Sonnenberger.Sh ERRORS 1460d5acd74SJohn MarinoThe 147*5b25d67aSSascha Wildner.Fn wcsrtombs , 148*5b25d67aSSascha Wildner.Fn wcsrtombs_l , 149*5b25d67aSSascha Wildner.Fn wcsnrtombs , 1500d5acd74SJohn Marinoand 151*5b25d67aSSascha Wildner.Fn wcsnrtombs_l 1520d5acd74SJohn Marinofunctions will fail if: 153eee2ef09SJoerg Sonnenberger.Bl -tag -width Er 154eee2ef09SJoerg Sonnenberger.It Bq Er EILSEQ 1550d5acd74SJohn MarinoAn invalid wide character was encountered. 1560d5acd74SJohn Marino.It Bq Er EINVAL 1570d5acd74SJohn MarinoThe conversion state is invalid. 158eee2ef09SJoerg Sonnenberger.El 159eee2ef09SJoerg Sonnenberger.Sh SEE ALSO 1600d5acd74SJohn Marino.Xr mbsrtowcs 3 , 161eee2ef09SJoerg Sonnenberger.Xr wcrtomb 3 , 162*5b25d67aSSascha Wildner.Xr wcstombs 3 , 163*5b25d67aSSascha Wildner.Xr xlocale 3 164eee2ef09SJoerg Sonnenberger.Sh STANDARDS 165eee2ef09SJoerg SonnenbergerThe 166eee2ef09SJoerg Sonnenberger.Fn wcsrtombs 167eee2ef09SJoerg Sonnenbergerfunction conforms to 168eee2ef09SJoerg Sonnenberger.St -isoC-99 . 1690d5acd74SJohn Marino.Pp 1700d5acd74SJohn MarinoThe 171*5b25d67aSSascha Wildner.Fn wcsrtombs_l , 172*5b25d67aSSascha Wildner.Fn wcsnrtombs , 173*5b25d67aSSascha Wildnerand 174*5b25d67aSSascha Wildner.Fn wcsnrtombs_l 175*5b25d67aSSascha Wildnerfunctions are an extension to the standard. 176