tst-iconv1.c 967 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /* Test case by yaoz@nih.gov. */
  2. #include <stddef.h>
  3. #include <stdio.h>
  4. #include <string.h>
  5. #if defined(__GLIBC__) && !defined(__UCLIBC__)
  6. #include <iconv.h>
  7. #endif
  8. static int
  9. do_test (void)
  10. {
  11. #if defined(__GLIBC__) && !defined(__UCLIBC__)
  12. char utf8[5];
  13. wchar_t ucs4[5];
  14. iconv_t cd;
  15. char *inbuf;
  16. char *outbuf;
  17. size_t inbytes;
  18. size_t outbytes;
  19. size_t n;
  20. strcpy (utf8, "abcd");
  21. /* From UTF8 to UCS4. */
  22. cd = iconv_open ("UCS4", "UTF8");
  23. if (cd == (iconv_t) -1)
  24. {
  25. perror ("iconv_open");
  26. return 1;
  27. }
  28. inbuf = utf8;
  29. inbytes = 4;
  30. outbuf = (char *) ucs4;
  31. outbytes = 4 * sizeof (wchar_t); /* "Argument list too long" error. */
  32. n = iconv (cd, &inbuf, &inbytes, &outbuf, &outbytes);
  33. if (n == (size_t) -1)
  34. {
  35. printf ("iconv: %m\n");
  36. iconv_close (cd);
  37. return 1;
  38. }
  39. iconv_close (cd);
  40. return 0;
  41. #else
  42. return 23;
  43. #endif
  44. }
  45. #define TEST_FUNCTION do_test ()
  46. #include "../test-skeleton.c"