c/string/multibyte/wcstombs

@1@ Converts a sequence of wide characters from the array whose first element is pointed to by to its narrow multibyte representation that begins in the initial shift state. Converted characters are stored in the successive elements of the char array pointed to by. No more than bytes are written to the destination array. @@ Each character is converted as if by a call to wctomb, except that the wctomb's conversion state is unaffected. The conversion stops if: @@* The null character was converted and stored. The bytes stored in this case are the unshift sequence (if necessary) followed by , @@* A was found that does not correspond to a valid character in the current C locale. @@* The next multibyte character to be stored would exceed. @@If and  overlap, the behavior is unspecified. @2@ Same as, except that @@* conversion is as-if by wcrtomb, not wctomb @@* the function returns its result as an out-parameter @@* if the conversion stops without writing a null character, the function will store in the next byte in, which may be  or , whichever comes first (meaning up to len+1/dstsz+1 total bytes may be written). In this case, there may be no unshift sequence written before the terminating null. @@* if is a null pointer, the number of bytes that would be produced is stored in @@* the function clobbers the destination array from the terminating null and until @@* If and  overlap, the behavior is unspecified. @@* the following errors are detected at runtime and call the currently installed constraint handler function:
 * or is a null pointer
 * or is greater than rsize_max (unless  is null)
 * is not zero (unless is null)
 * is greater than and the conversion does not encounter null or encoding error in the  array by the time  is reached (unless  is null)

Return value
@1@ On success, returns the number of bytes (including any shift sequences, but excluding the terminating ) written to the character array whose first element is pointed to by. On conversion error (if invalid wide character was encountered), returns. @2@ Returns zero on success (in which case the number of bytes excluding terminating zero that were, or would be written to, is stored in ), non-zero on error. In case of a runtime constraint violation, stores in  (unless  is null) and sets  to  (unless  is null or  is zero or greater than rsize_max)