.
[glibc/history.git] / intl / tst-gettext3.c
blob917967b3834d1bc1125de436b311695a35d54642
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, 2005 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5 Contributed by Bruno Haible <bruno@clisp.org>, 2001, 2005.
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.
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.
17 You should have received a copy of the GNU Lesser General Public
18 License along with the GNU C Library; if not, write to the Free
19 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 02111-1307 USA. */
22 #include <libintl.h>
23 #include <locale.h>
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <string.h>
28 int
29 main (void)
31 char *s;
32 int result = 0;
34 unsetenv ("LANGUAGE");
35 unsetenv ("OUTPUT_CHARSET");
36 textdomain ("codeset");
37 bindtextdomain ("codeset", OBJPFX "domaindir");
39 setlocale (LC_ALL, "de_DE.ISO-8859-1");
41 /* Here we expect output in ISO-8859-1. */
42 s = gettext ("cheese");
43 if (strcmp (s, "K\344se"))
45 printf ("call 1 returned: %s\n", s);
46 result = 1;
49 setlocale (LC_ALL, "de_DE.UTF-8");
51 /* Here we expect output in UTF-8. */
52 s = gettext ("cheese");
53 if (strcmp (s, "K\303\244se"))
55 printf ("call 2 returned: %s\n", s);
56 result = 1;
59 return result;