'\" te .\" Copyright (c) 2003, Sun Microsystems, Inc. All Rights Reserved. .TH wcstombs 3C "1 Nov 2003" "SunOS 5.11" "Standard C Library Functions" .SH NAME wcstombs \- convert a wide-character string to a character string .SH SYNOPSIS .LP .nf #include \fBsize_t\fR \fBwcstombs\fR(\fBchar *restrict\fR \fIs\fR, \fBconst wchar_t *restrict\fR \fIpwcs\fR, \fBsize_t\fR \fIn\fR); .fi .SH DESCRIPTION .sp .LP The \fBwcstombs()\fR function converts the sequence of wide-character codes from the array pointed to by \fIpwcs\fR into a sequence of characters and stores these characters into the array pointed to by \fIs\fR, stopping if a character would exceed the limit of \fIn\fR total bytes or if a null byte is stored. Each wide-character code is converted as if by a call to \fBwctomb\fR(3C). .sp .LP The behavior of this function is affected by the \fBLC_CTYPE\fR category of the current locale. .sp .LP No more than \fIn\fR bytes will be modified in the array pointed to by \fIs\fR. If copying takes place between objects that overlap, the behavior is undefined. If \fIs\fR is a null pointer, \fBwcstombs()\fR returns the length required to convert the entire array regardless of the value of \fIn\fR, but no values are stored. .SH RETURN VALUES .sp .LP If a wide-character code is encountered that does not correspond to a valid character (of one or more bytes each), \fBwcstombs()\fR returns (\fBsize_t\fR)\fB-1\fR. Otherwise, \fBwcstombs()\fR returns the number of bytes stored in the character array, not including any terminating null byte. The array will not be null-terminated if the value returned is \fIn\fR. .SH ERRORS .sp .LP The \fBwcstombs()\fR function may fail if: .sp .ne 2 .mk .na \fB\fBEILSEQ\fR\fR .ad .RS 10n .rt A wide-character code does not correspond to a valid character. .RE .SH ATTRIBUTES .sp .LP See \fBattributes\fR(5) for descriptions of the following attributes: .sp .sp .TS tab() box; lw(2.75i) |lw(2.75i) lw(2.75i) |lw(2.75i) . ATTRIBUTE TYPEATTRIBUTE VALUE _ CSIEnabled _ Interface StabilityCommitted _ MT-LevelMT-Safe _ StandardSee \fBstandards\fR(5). .TE .SH SEE ALSO .sp .LP \fBmblen\fR(3C), \fBmbstowcs\fR(3C), \fBmbtowc\fR(3C), \fBsetlocale\fR(3C), \fBwctomb\fR(3C), \fBattributes\fR(5), \fBstandards\fR(5)