convert a wide character to a multibyte character
#include <stdlib.h> int wctomb( char *s, wchar_t wchar );
The wctomb() function determines the number of bytes required to represent the multibyte character corresponding to the code contained in wchar. If s is not a NULL pointer, the multibyte character representation is stored in the array pointed to by s. At most MB_CUR_MAX characters will be stored.
If s is a NULL pointer, the wctomb() function returns zero if multibyte character encodings do not have state-dependent encoding, and non-zero otherwise.
If s is not a NULL pointer, the wctomb() function returns:
mblen(), mbstowcs(), mbtowc(), wcstombs()
#include <stdio.h> #include <stdlib.h> wchar_t wchar = { 0x0073 }; char mbbuffer[MB_CUR_MAX]; void main() { int len; printf( "Character encodings do %shave " "state-dependent \nencoding.\n", ( wctomb( NULL, 0 ) ) ? "" : "not " ); len = wctomb( mbbuffer, wchar ); mbbuffer[len] = '\0'; printf( "%s(%d)\n", mbbuffer, len ); }
produces the output:
Character encodings do not have state-dependent encoding. s(1)
ANSI
All (except DOS/PM)