This repository has been archived on 2024-12-16. You can view files and clone it, but cannot push or open issues or pull requests.
CodeBlocksPortable/WATCOM/samples/clibexam/mbtowc.c

23 lines
504 B
C

#include <stdio.h>
#include <stdlib.h>
#include <mbctype.h>
void main()
{
char *wc = "string";
wchar_t wbuffer[10];
int i, len;
_setmbcp( 932 );
printf( "Character encodings are %sstate dependent\n",
( mbtowc( wbuffer, NULL, 0 ) )
? "" : "not " );
len = mbtowc( wbuffer, wc, MB_CUR_MAX );
wbuffer[len] = '\0';
printf( "%s(%d)\n", wc, len );
for( i = 0; i < len; i++ )
printf( "/%4.4x", wbuffer[i] );
printf( "\n" );
}