1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 2010, 2011, 2012 Free Software Foundation, Inc.
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.
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.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
23 #include "libpspp/i18n.h"
29 main (int argc, char *argv[])
33 if (argc > 1 && !strcmp (argv[1], "supports_encodings"))
38 for (i = 2; i < argc; i++)
39 if (!is_encoding_supported (argv[i]))
41 printf ("encoding \"%s\" is NOT supported\n", argv[i]);
47 if (argc == 5 && !strcmp (argv[1], "recode"))
49 const char *from = argv[2];
50 const char *to = argv[3];
51 const char *string = argv[4];
52 char *result = recode_string (to, from, string, -1);
54 assert (strlen (result) == recode_string_len (to, from, string, -1));
57 else if (argc == 6 && !strcmp (argv[1], "concat"))
59 const char *head = argv[2];
60 const char *tail = argv[3];
61 const char *encoding = argv[4];
62 int max_len = atoi (argv[5]);
65 result = utf8_encoding_concat (head, tail, encoding, max_len);
68 assert (strlen (result)
69 == utf8_encoding_concat_len (head, tail, encoding, max_len));
73 char *result2 = utf8_encoding_trunc (head, encoding, max_len);
74 assert (!strcmp (result, result2));
75 assert (strlen (result2)
76 == utf8_encoding_trunc_len (head, encoding, max_len));
85 usage: %s supports_encodings ENCODING...\n\
86 where ENCODING is the name of an encoding.\n\
87 Exits with status 0 if all the encodings are supported, 77 otherwise.\n\
89 usage: %s recode FROM TO STRING\n\
90 where FROM is the source encoding,\n\
91 TO is the target encoding,\n\
92 and STRING is the text to recode.\n\
94 usage: %s concat HEAD TAIL ENCODING MAX_LEN\n\
95 where HEAD is the first string to concatenate\n\
96 TAIL is the second string to concatenate\n\
97 ENCODING is the encoding in which to measure the result's length\n\
98 MAX_LEN is the maximum length of the result in ENCODING.\n",
99 argv[0], argv[0], argv[0]);