1 /* Based on a test program by Won Kyu Park <wkpark@chem.skku.ac.kr>. */
15 char buf
[100], *pchar
;
17 wchar_t tmp1
[] = { L
'W', L
'o', L
'r', L
'l', L
'd', L
'\0' };
21 pchar
= setlocale (LC_ALL
, "");
22 printf ("locale : %s\n",pchar
);
23 printf ("MB_CUR_MAX %Zd\n", MB_CUR_MAX
);
25 puts ("---- test 1 ------");
26 test
= mbstowcs (tmp
, str
, (strlen (str
) + 1) * sizeof (char));
27 printf ("size of string by mbstowcs %d\n", test
);
28 if (test
!= strlen (str
))
30 idx
+= wctomb (&buf
[0], tmp
[0]);
31 idx
+= wctomb (&buf
[idx
], tmp
[1]);
33 printf ("orig string %s\n", str
);
34 printf ("string by wctomb %s\n", buf
);
35 printf ("string by %%C %C", (wint_t) tmp
[0]);
38 printf ("%C\n", (wint_t) tmp
[1]);
41 printf ("string by %%S %S\n", tmp
);
42 if (wcscmp (tmp
, L
"Hello") != 0)
44 puts ("---- test 2 ------");
45 printf ("wchar string %S\n", tmp1
);
46 printf ("wchar %C\n", (wint_t) tmp1
[0]);
47 test
= wcstombs (buf
, tmp1
, (wcslen (tmp1
) + 1) * sizeof (wchar_t));
48 printf ("size of string by wcstombs %d\n", test
);
49 if (test
!= wcslen (tmp1
))
52 printf ("size of string by wcslen %d\n", test
);
53 printf ("char %s\n", buf
);
54 if (strcmp (buf
, "World") != 0)
56 puts ("------------------");