mirror of
https://github.com/Stichting-MINIX-Research-Foundation/netbsd.git
synced 2025-08-15 17:10:34 -04:00
31 lines
640 B
C
31 lines
640 B
C
/* From: Miloslav Trmac <mitr@volny.cz> */
|
|
#include <langinfo.h>
|
|
#include <limits.h>
|
|
#include <locale.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
int
|
|
main(void)
|
|
{
|
|
wchar_t wc;
|
|
char back[MB_LEN_MAX];
|
|
int ret;
|
|
size_t i;
|
|
|
|
setlocale(LC_ALL, "");
|
|
printf("Charset: %s\n", nl_langinfo(CODESET));
|
|
ret = mbtowc(&wc, "\xe4", 1);
|
|
printf("mbtowc(): %d\n", ret);
|
|
if(ret > 0) {
|
|
printf("Result: 0x%08lX\n",(unsigned long)wc);
|
|
ret = wctomb(back, wc);
|
|
printf("wctomb(): %d\n", ret);
|
|
for(i = 0; ret > 0 && i <(size_t)ret; i++)
|
|
printf("%02X ",(unsigned char)back[i]);
|
|
putchar('\n');
|
|
return EXIT_SUCCESS;
|
|
} else
|
|
return EXIT_FAILURE;
|
|
}
|