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