1.\" $NetBSD: wcrtomb.3,v 1.2 2002/03/18 07:56:29 wiz Exp $ 2.\" 3.\" Copyright (c)2002 Citrus Project, 4.\" All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 15.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25.\" SUCH DAMAGE. 26.\" 27.Dd February 4, 2002 28.Dt WCRTOMB 3 29.Os 30.\" ---------------------------------------------------------------------- 31.Sh NAME 32.Nm wcrtomb 33.Nd converts a wide character to a multibyte character (restartable) 34.\" ---------------------------------------------------------------------- 35.Sh LIBRARY 36.Lb libc 37.\" ---------------------------------------------------------------------- 38.Sh SYNOPSIS 39.Fd #include \*[Lt]wchar.h\*[Gt] 40.Ft size_t 41.Fn wcrtomb "const char * restrict s" "wchar_t wc" "mbstate_t * restrict ps" 42.\" ---------------------------------------------------------------------- 43.Sh DESCRIPTION 44The 45.Fn wcrtomb 46converts the wide character given by 47.Fa wc 48to the corresponding multibyte character, and stores it to the array 49pointed by 50.Fa s 51unless 52.Fa s 53is null pointer. 54This function will modify the first at most MB_CUR_MAX bytes of the 55array pointed by 56.Fa s . 57.Pp 58The behaviour of the 59.Fn wcrtomb 60is affected by LC_CTYPE category of the current locale. 61.Pp 62There are the special cases: 63.Bl -tag -width 012345678901 64.It "wc == 0" 65For state-dependent encodings, the 66.Fn wcrtomb 67stores a null byte preceded by special byte sequence (if any) 68to back to a initial state to the array pointed by 69.Fa s , 70and the state object pointed by 71.Fa ps 72also back to a initial state. 73.It "s == NULL" 74The 75.Fn wcrtomb 76just places 77.Fa ps 78into a initial state. 79It is equivalent to the following call: 80.Bd -literal 81wcrtomb(buf, L'\\0', ps); 82.Ed 83.Pp 84Here, 85.Fa buf 86is a dummy buffer. 87In this case, 88.Fa wc 89is ignored. 90.It "ps == NULL" 91The 92.Fn mbrtowc 93uses its own internal state object to keep the conversion state, 94instead of 95.Fa ps 96mentioned in this manual page. 97.Pp 98Calling any other functions in the 99.Lb libc 100never change the internal 101state of the 102.Fn mbrtowc , 103that is initialized at startup time of the program. 104.El 105.\" ---------------------------------------------------------------------- 106.Sh RETURN VALUES 107The 108.Fn wcrtomb 109returns 110.Bl -tag -width 012345678901 111.It "positive" 112The number of bytes (including any shift sequences) 113which is stored in the array. 114.It "(size_t)-1" 115.Fa wc 116is not valid wide character. 117In this case, the 118.Fn wcrtomb 119also sets errno to indicate error. 120.El 121.\" ---------------------------------------------------------------------- 122.Sh ERRORS 123The 124.Fn wcrtomb 125may causes an error in the following case: 126.Bl -tag -width Er 127.It Bq Er EILSEQ 128.Fa wc 129is not valid wide character. 130.It Bq Er EINVAL 131.Fa ps 132points an invalid or uninitialized mbstate_t object. 133.El 134.\" ---------------------------------------------------------------------- 135.Sh SEE ALSO 136.Xr setlocale 3 , 137.Xr wctomb 3 138.\" ---------------------------------------------------------------------- 139.Sh STANDARDS 140The 141.Fn wcrtomb 142function conforms to 143.St -isoC-amd1 . 144The restrict qualifier is added at 145.St -isoC99 . 146