• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Test program, used by the intl-setlocale-2 test.
2    Copyright (C) 2005, 2007, 2013, 2018 Free Software Foundation, Inc.
3 
4    This program is free software: you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation; either version 3 of the License, or
7    (at your option) any later version.
8 
9    This program 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
12    GNU General Public License for more details.
13 
14    You should have received a copy of the GNU General Public License
15    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
16 
17 /* Written by Bruno Haible <haible@clisp.cons.org>, 2005.  */
18 
19 #ifdef HAVE_CONFIG_H
20 # include <config.h>
21 #endif
22 
23 #include <locale.h>
24 #include <stdlib.h>
25 #include <stdio.h>
26 #include <string.h>
27 
28 #if USE_SYSTEM_LIBINTL
29 # include <libintl.h>
30 #else
31 /* Make sure we use the included libintl, not the system's one. */
32 # undef _LIBINTL_H
33 # include "libgnuintl.h"
34 #endif
35 
36 int
main(void)37 main (void)
38 {
39   char *s;
40   int result = 0;
41 
42   unsetenv ("LANGUAGE");
43   unsetenv ("OUTPUT_CHARSET");
44   textdomain ("tstprog");
45   bindtextdomain ("tstprog", "in-sl-2");
46 
47   setlocale (LC_ALL, "de_DE.ISO-8859-1");
48 
49   /* Here we expect output in ISO-8859-1.  */
50   s = gettext ("cheese");
51   if (strcmp (s, "K\344se"))
52     {
53       fprintf (stderr, "call 1 returned: %s\n", s);
54       result = 1;
55     }
56 
57   setlocale (LC_ALL, "de_DE.UTF-8");
58 
59   /* Here we expect output in UTF-8.  */
60   s = gettext ("cheese");
61   if (strcmp (s, "K\303\244se"))
62     {
63       fprintf (stderr, "call 2 returned: %s\n", s);
64       result = 1;
65     }
66 
67   return result;
68 }
69