summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '3rdParty/LibIDN/src/toutf8.c')
-rw-r--r--3rdParty/LibIDN/src/toutf8.c60
1 files changed, 33 insertions, 27 deletions
diff --git a/3rdParty/LibIDN/src/toutf8.c b/3rdParty/LibIDN/src/toutf8.c
index 0d82717..b7126e2 100644
--- a/3rdParty/LibIDN/src/toutf8.c
+++ b/3rdParty/LibIDN/src/toutf8.c
@@ -1,25 +1,33 @@
1/* toutf8.c --- Convert strings from system locale into UTF-8. 1/* toutf8.c --- Convert strings from system locale into UTF-8.
2 * Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Simon Josefsson 2 Copyright (C) 2002-2015 Simon Josefsson
3 * 3
4 * This file is part of GNU Libidn. 4 This file is part of GNU Libidn.
5 * 5
6 * GNU Libidn is free software; you can redistribute it and/or 6 GNU Libidn is free software: you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public 7 modify it under the terms of either:
8 * License as published by the Free Software Foundation; either 8
9 * version 2.1 of the License, or (at your option) any later version. 9 * the GNU Lesser General Public License as published by the Free
10 * 10 Software Foundation; either version 3 of the License, or (at
11 * GNU Libidn is distributed in the hope that it will be useful, 11 your option) any later version.
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 or
14 * Lesser General Public License for more details. 14
15 * 15 * the GNU General Public License as published by the Free
16 * You should have received a copy of the GNU Lesser General Public 16 Software Foundation; either version 2 of the License, or (at
17 * License along with GNU Libidn; if not, write to the Free Software 17 your option) any later version.
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 18
19 * 19 or both in parallel, as here.
20 */ 20
21 GNU Libidn is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 General Public License for more details.
25
26 You should have received copies of the GNU General Public License and
27 the GNU Lesser General Public License along with this program. If
28 not, see <http://www.gnu.org/licenses/>. */
21 29
22#ifdef HAVE_CONFIG_H 30#ifdef HAVE_CONFIG_H
23# include "config.h" 31# include "config.h"
24#endif 32#endif
25 33
@@ -42,23 +50,21 @@
42# define HAVE_ICONV 1 50# define HAVE_ICONV 1
43# define HAVE_LOCALE_H 1 51# define HAVE_LOCALE_H 1
44# define HAVE_LANGINFO_CODESET 1 52# define HAVE_LANGINFO_CODESET 1
45#endif 53#endif
46 54
47#if HAVE_LOCALE_H 55#include <locale.h>
48# include <locale.h>
49#endif
50 56
51#if HAVE_LANGINFO_CODESET 57#ifdef HAVE_LANGINFO_CODESET
52# include <langinfo.h> 58# include <langinfo.h>
53#endif 59#endif
54 60
55#ifdef _LIBC 61#ifdef _LIBC
56# define stringprep_locale_charset() nl_langinfo (CODESET) 62# define stringprep_locale_charset() nl_langinfo (CODESET)
57#else 63#else
58/** 64/**
59 * stringprep_locale_charset - return charset used in current locale 65 * stringprep_locale_charset:
60 * 66 *
61 * Find out current locale charset. The function respect the CHARSET 67 * Find out current locale charset. The function respect the CHARSET
62 * environment variable, but typically uses nl_langinfo(CODESET) when 68 * environment variable, but typically uses nl_langinfo(CODESET) when
63 * it is supported. It fall back on "ASCII" if CHARSET isn't set and 69 * it is supported. It fall back on "ASCII" if CHARSET isn't set and
64 * nl_langinfo isn't supported or return anything. 70 * nl_langinfo isn't supported or return anything.
@@ -93,11 +99,11 @@ stringprep_locale_charset (void)
93 return "ASCII"; 99 return "ASCII";
94} 100}
95#endif 101#endif
96 102
97/** 103/**
98 * stringprep_convert - encode string using new character set 104 * stringprep_convert:
99 * @str: input zero-terminated string. 105 * @str: input zero-terminated string.
100 * @to_codeset: name of destination character set. 106 * @to_codeset: name of destination character set.
101 * @from_codeset: name of origin character set, as used by @str. 107 * @from_codeset: name of origin character set, as used by @str.
102 * 108 *
103 * Convert the string from one character set to another using the 109 * Convert the string from one character set to another using the
@@ -122,11 +128,11 @@ stringprep_convert (const char *str,
122 return strcpy (p, str); 128 return strcpy (p, str);
123#endif 129#endif
124} 130}
125 131
126/** 132/**
127 * stringprep_locale_to_utf8 - convert locale encoded string to UTF-8 133 * stringprep_locale_to_utf8:
128 * @str: input zero terminated string. 134 * @str: input zero terminated string.
129 * 135 *
130 * Convert string encoded in the locale's character set into UTF-8 by 136 * Convert string encoded in the locale's character set into UTF-8 by
131 * using stringprep_convert(). 137 * using stringprep_convert().
132 * 138 *
@@ -138,11 +144,11 @@ stringprep_locale_to_utf8 (const char *str)
138{ 144{
139 return stringprep_convert (str, "UTF-8", stringprep_locale_charset ()); 145 return stringprep_convert (str, "UTF-8", stringprep_locale_charset ());
140} 146}
141 147
142/** 148/**
143 * stringprep_utf8_to_locale - encode UTF-8 string to locale encoding 149 * stringprep_utf8_to_locale:
144 * @str: input zero terminated string. 150 * @str: input zero terminated string.
145 * 151 *
146 * Convert string encoded in UTF-8 into the locale's character set by 152 * Convert string encoded in UTF-8 into the locale's character set by
147 * using stringprep_convert(). 153 * using stringprep_convert().
148 * 154 *