WCTOMB - convert wide character to multibyte.

(ANSI Standard)


#include <stdlib.h>
length = wctomb(mb,wc);


char *mb;
is either a null pointer or a pointer to a memory area where a multibyte character may be stored. Such a memory area should be large enough to store a character that is MB_CUR_MAX bytes long (the length of the longest multibyte character in the current locale).
wchar_t wc;
is a wide character.
int length;
is the length of the resulting multibyte character (but see below).


The "wctomb" function converts the wide character "wc" into a multibyte character and stores it in the memory indicated by "mb". If the "wc" value cannot be converted into a valid multibyte character for the current locale, "wctomb" returns -1. Otherwise, it returns the number of bytes in the multibyte character stored in "*mb". This could be zero if "wc" is zero. It is always less than or equal to MB_CUR_MAX.

If the "mb" argument is a null pointer, "wctomb" returns 0 if multibyte characters do not have shift-dependencies, and a non-zero value otherwise.

NOTE: if the current locale has shift dependencies, "wctomb" keeps track of the current shift state. Calling "wctomb" with a null pointer for "mb" puts "wctomb" into the initial shift state. Otherwise, "wctomb" assumes that it should write out the multibyte character beginning with the shift state that "wctomb" had at the end of its last call. After converting a "wc" value of zero, "wctomb" goes back to the initial shift state.

See Also:

expl nsc lib mblen

expl nsc lib mbstowcs

expl nsc lib mbtowc

expl nsc lib wcstombs

Copyright © 1996, Thinkage Ltd.