wcstombs

Converts a wide-character string into a multibyte character string.

Library:LibC
Classification:ANSI
Service:General C Services

Syntax

  #include <stdlib.h> 
   
  size_t wcstombs (
     char            *s,
     const wchar_t   *pwcs,
     size_t           n);
  

Parameters

s

(OUT) Points to the array of multibyte characters.

pwcs

(IN) Points to the array of wide-character codes to be converted.

n

(IN) Specifies the maximum length of the s parameter.

Return Values

If successful, returns the actual number of bytes stored in the s array. If the return value is equal to n, the string is not null-terminated.

If a wide-character code is encountered that cannot be converted, returns -1 and sets errno to the following:

Decimal

Constant

Description

101

EILSEQ

A wide-character code does not correspond to a valid character.

Remarks

The wcstombs function converts a sequence of wide-character codes from the array pointed to by pwcs into a sequence of multibyte characters and stores them in the array pointed to by s. The wcstombs function stops if a multibyte character would exceed the limit of n total bytes, or if the null-terminating character is stored. At most, n bytes are modified.

See Also