]> sjero.net Git - wget/blob - src/iri.c
Introduce find_locale() to find out local system encoding.
[wget] / src / iri.c
1 /* IRI related functions.
2    Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
3    2008 Free Software Foundation, Inc.
4
5 This file is part of GNU Wget.
6
7 GNU Wget is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or (at
10 your option) any later version.
11
12 GNU Wget 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
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with Wget.  If not, see <http://www.gnu.org/licenses/>.
19
20 Additional permission under GNU GPL version 3 section 7
21
22 If you modify this program, or any covered work, by linking or
23 combining it with the OpenSSL project's OpenSSL library (or a
24 modified version of that library), containing parts covered by the
25 terms of the OpenSSL or SSLeay licenses, the Free Software Foundation
26 grants you additional permission to convey the resulting work.
27 Corresponding Source for a non-source form of such a combination
28 shall include the source code for the parts of OpenSSL used as well
29 as that of the covered work.  */
30
31 #include "wget.h"
32
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <assert.h>
36 #include <string.h>
37
38 #include "utils.h"
39 #include "iri.h"
40
41
42 /* Given a string containing "charset=XXX", return the encoding if found,
43    or NULL otherwise */
44 char *
45 parse_charset (char *str)
46 {
47   char *charset;
48
49   if (!str || !*str)
50     return NULL;
51
52   str = strcasestr (str, "charset=");
53   if (!str)
54     return NULL;
55
56   str += 8;
57   charset = str;
58
59   /* sXXXav: which chars should be banned ??? */
60   while (*charset && !c_isspace (*charset))
61     charset++;
62
63   /* sXXXav: could strdupdelim return NULL ? */
64   charset = strdupdelim (str, charset);
65   logprintf (LOG_VERBOSE, "parse_charset: %s\n", quote (charset));
66
67   return charset;
68 }
69
70
71 /* Find the locale used, or fall back on a default value */
72 char *
73 find_locale (void)
74 {
75   /* sXXXav, made our own function or use libidn one ?! */
76   return stringprep_locale_charset ();
77 }
78
79