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