tst-codeset.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /* Test of bind_textdomain_codeset.
  2. Copyright (C) 2001-2026 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <https://www.gnu.org/licenses/>. */
  15. #include <libintl.h>
  16. #include <locale.h>
  17. #include <stdio.h>
  18. #include <stdlib.h>
  19. #include <string.h>
  20. #include <support/check.h>
  21. static int
  22. do_test (void)
  23. {
  24. unsetenv ("LANGUAGE");
  25. unsetenv ("OUTPUT_CHARSET");
  26. setlocale (LC_ALL, "de_DE.ISO-8859-1");
  27. textdomain ("codeset");
  28. bindtextdomain ("codeset", OBJPFX "domaindir");
  29. /* Here we expect output in ISO-8859-1. */
  30. TEST_COMPARE_STRING (gettext ("cheese"), "K\344se");
  31. /* Here we expect output in UTF-8. */
  32. bind_textdomain_codeset ("codeset", "UTF-8");
  33. TEST_COMPARE_STRING (gettext ("cheese"), "K\303\244se");
  34. /* `a with umlaut' is transliterated to `ae'. */
  35. bind_textdomain_codeset ("codeset", "ASCII//TRANSLIT");
  36. TEST_COMPARE_STRING (gettext ("cheese"), "Kaese");
  37. /* Transliteration also works by default even if not set. */
  38. bind_textdomain_codeset ("codeset", "ASCII");
  39. TEST_COMPARE_STRING (gettext ("cheese"), "Kaese");
  40. return 0;
  41. }
  42. #include <support/test-driver.c>