(ANSI Standard)
#include <stdlib.h> length = wctomb(mb,wc);
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.
Copyright © 1996, Thinkage Ltd.