tst-codeset.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* Test of bind_textdomain_codeset.
  2. Copyright (C) 2001-2019 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. Contributed by Bruno Haible <haible@clisp.cons.org>, 2001.
  5. The GNU C Library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with the GNU C Library; if not, see
  15. <http://www.gnu.org/licenses/>. */
  16. #include <libintl.h>
  17. #include <locale.h>
  18. #include <stdio.h>
  19. #include <stdlib.h>
  20. #include <string.h>
  21. static int
  22. do_test (void)
  23. {
  24. char *s;
  25. int result = 0;
  26. unsetenv ("LANGUAGE");
  27. unsetenv ("OUTPUT_CHARSET");
  28. setlocale (LC_ALL, "de_DE.ISO-8859-1");
  29. textdomain ("codeset");
  30. bindtextdomain ("codeset", OBJPFX "domaindir");
  31. /* Here we expect output in ISO-8859-1. */
  32. s = gettext ("cheese");
  33. if (strcmp (s, "K\344se"))
  34. {
  35. printf ("call 1 returned: %s\n", s);
  36. result = 1;
  37. }
  38. bind_textdomain_codeset ("codeset", "UTF-8");
  39. /* Here we expect output in UTF-8. */
  40. s = gettext ("cheese");
  41. if (strcmp (s, "K\303\244se"))
  42. {
  43. printf ("call 2 returned: %s\n", s);
  44. result = 1;
  45. }
  46. return result;
  47. }
  48. #define TEST_FUNCTION do_test ()
  49. #include "../test-skeleton.c"