25 lines
561 B
C
25 lines
561 B
C
#define __STDC_WANT_LIB_EXT1__ 1
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
wchar_t wchar = { 0x0073 };
|
|
char mbbuffer[3];
|
|
int main()
|
|
{
|
|
int len;
|
|
int status;
|
|
errno_t rc;
|
|
rc = wctomb_s( &status, NULL, 0, wchar );
|
|
printf( "Character encodings are %sstate dependent\n",
|
|
( status ) ? "" : "not " );
|
|
|
|
rc = wctomb_s( &len, mbbuffer, 2, wchar );
|
|
if( rc != 0) {
|
|
printf( "Character encoding error\n");
|
|
} else {
|
|
mbbuffer[len] = '\0';
|
|
printf( "%s(%d)\n", mbbuffer, len );
|
|
}
|
|
return( rc );
|
|
}
|