1 /* Recode strings between character sets, using iconv.
2 Copyright (C) 2004, 2005 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 2, or (at your option)
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 along
16 with this program; if not, write to the Free Software Foundation,
17 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
24 int main (int ac, char *av[])
26 char *in = NULL, *out = NULL;
27 char *to = NULL, *from = NULL;
41 printf ("Enter string to convert:\n\t> ");
42 if (getline (&in, &len, stdin) < 0)
44 if (in[strlen (in) - 1] == '\n')
45 in[strlen (in) - 1] = '\0';
51 printf ("Enter destination code set:\n\t> ");
52 if (getline (&to, &len, stdin) < 0)
54 if (to[strlen (to) - 1] == '\n')
55 to[strlen (to) - 1] = '\0';
61 printf ("Enter source code set:\n\t> ");
62 if (getline (&from, &len, stdin) < 0)
64 if (from[strlen (from) - 1] == '\n')
65 from[strlen (from) - 1] = '\0';
68 printf (" Input string: `%s'\n"
69 "From code set: `%s'\n"
70 " To code set: `%s'\n",
73 out = iconv_string (in, from, to);
79 printf ("\nOutput: `%s'\n", out);