1 /* Recode strings between character sets, using iconv.
2 Copyright (C) 2004-2005, 2009-2011 Free Software Foundation, Inc.
3 Written by Simon Josefsson.
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
25 int main (int ac
, char *av
[])
27 char *in
= NULL
, *out
= NULL
;
28 char *to
= NULL
, *from
= NULL
;
42 printf ("Enter string to convert:\n\t> ");
43 if (getline (&in
, &len
, stdin
) < 0)
45 if (in
[strlen (in
) - 1] == '\n')
46 in
[strlen (in
) - 1] = '\0';
52 printf ("Enter destination code set:\n\t> ");
53 if (getline (&to
, &len
, stdin
) < 0)
55 if (to
[strlen (to
) - 1] == '\n')
56 to
[strlen (to
) - 1] = '\0';
62 printf ("Enter source code set:\n\t> ");
63 if (getline (&from
, &len
, stdin
) < 0)
65 if (from
[strlen (from
) - 1] == '\n')
66 from
[strlen (from
) - 1] = '\0';
69 printf (" Input string: `%s'\n"
70 "From code set: `%s'\n"
71 " To code set: `%s'\n",
74 out
= iconv_string (in
, from
, to
);
80 printf ("\nOutput: `%s'\n", out
);