testmb2.c 542 B

12345678910111213141516171819202122232425262728293031
  1. /* Test case by Miloslav Trmac <mitr@volny.cz>. */
  2. #include <locale.h>
  3. #include <stdint.h>
  4. #include <stdlib.h>
  5. #include <stdio.h>
  6. int
  7. main (void)
  8. {
  9. wchar_t wc;
  10. if (setlocale (LC_CTYPE, "de_DE.UTF-8") == NULL)
  11. {
  12. puts ("setlocale failed");
  13. return 1;
  14. }
  15. if (mbtowc (&wc, "\xc3\xa1", MB_CUR_MAX) != 2 || wc != 0xE1)
  16. {
  17. puts ("1st mbtowc failed");
  18. return 1;
  19. }
  20. if (mbtowc (&wc, "\xc3\xa1", SIZE_MAX) != 2 || wc != 0xE1)
  21. {
  22. puts ("2nd mbtowc failed");
  23. return 1;
  24. }
  25. return 0;
  26. }