wctomb Subroutine

Purpose

Converts a wide character into a multibyte character.

Library

Standard C Library (libc.a)

Syntax

#include <stdlib.h>
int wctomb ( Storage WideCharacter)
char *Storage;
wchar_t WideCharacter;

Description

The wctomb subroutine determines the number of bytes required to represent the wide character specified by the WideCharacter parameter as the corresponding multibyte character. It then converts the WideCharacter value to a multibyte character and stores the results in the area pointed to by the Storage parameter. The wctomb subroutine can store a maximum of MB_CUR_MAX bytes in the area pointed to by the Storage parameter. Thus, the length of the area pointed to by the Storage parameter should be at least MB_CUR_MAX bytes. The MB_CUR_MAX macro is defined in the stdlib.h file.

Parameters

Item Description
Storage Points to an area where the result of the conversion is stored.
WideCharacter Specifies a wide-character value.

Return Values

The wctomb subroutine returns a 0 if the Storage parameter is a null pointer. If the WideCharacter parameter does not correspond to a valid multibyte character, a -1 is returned. Otherwise, the number of bytes that comprise the multibyte character is returned.