diff options
Diffstat (limited to 'src/lib/nls.c')
-rw-r--r-- | src/lib/nls.c | 51 |
1 files changed, 32 insertions, 19 deletions
diff --git a/src/lib/nls.c b/src/lib/nls.c index f313ce59..08f74df8 100644 --- a/src/lib/nls.c +++ b/src/lib/nls.c | |||
@@ -55,7 +55,7 @@ GNUNET_GTK_setup_nls () | |||
55 | 55 | ||
56 | 56 | ||
57 | char * | 57 | char * |
58 | GNUNET_GTK_from_utf8_to_loc (gchar *str_utf8) | 58 | GNUNET_GTK_from_utf8_to_loc (gchar * str_utf8) |
59 | { | 59 | { |
60 | char *str_loc; | 60 | char *str_loc; |
61 | const char *loc_charset; | 61 | const char *loc_charset; |
@@ -68,13 +68,14 @@ GNUNET_GTK_from_utf8_to_loc (gchar *str_utf8) | |||
68 | if (is_UTF8) | 68 | if (is_UTF8) |
69 | str_loc = GNUNET_strdup (str_utf8); | 69 | str_loc = GNUNET_strdup (str_utf8); |
70 | else | 70 | else |
71 | str_loc = GNUNET_STRINGS_from_utf8 (str_utf8, strlen (str_utf8), loc_charset); | 71 | str_loc = |
72 | GNUNET_STRINGS_from_utf8 (str_utf8, strlen (str_utf8), loc_charset); | ||
72 | 73 | ||
73 | return str_loc; | 74 | return str_loc; |
74 | } | 75 | } |
75 | 76 | ||
76 | char * | 77 | char * |
77 | GNUNET_GTK_from_loc_to_utf8 (gchar *str_loc) | 78 | GNUNET_GTK_from_loc_to_utf8 (gchar * str_loc) |
78 | { | 79 | { |
79 | char *str_utf8; | 80 | char *str_utf8; |
80 | const char *loc_charset; | 81 | const char *loc_charset; |
@@ -94,21 +95,21 @@ GNUNET_GTK_from_loc_to_utf8 (gchar *str_loc) | |||
94 | 95 | ||
95 | /* This is copied from GLib */ | 96 | /* This is copied from GLib */ |
96 | static gboolean | 97 | static gboolean |
97 | get_filename_charset (const gchar **filename_charset) | 98 | get_filename_charset (const gchar ** filename_charset) |
98 | { | 99 | { |
99 | const gchar **charsets; | 100 | const gchar **charsets; |
100 | gboolean is_utf8; | 101 | gboolean is_utf8; |
101 | 102 | ||
102 | is_utf8 = g_get_filename_charsets (&charsets); | 103 | is_utf8 = g_get_filename_charsets (&charsets); |
103 | 104 | ||
104 | if (filename_charset) | 105 | if (filename_charset) |
105 | *filename_charset = charsets[0]; | 106 | *filename_charset = charsets[0]; |
106 | 107 | ||
107 | return is_utf8; | 108 | return is_utf8; |
108 | } | 109 | } |
109 | 110 | ||
110 | char * | 111 | char * |
111 | GNUNET_GTK_from_filename_to_utf8 (gchar *filename) | 112 | GNUNET_GTK_from_filename_to_utf8 (gchar * filename) |
112 | { | 113 | { |
113 | char *str_utf8; | 114 | char *str_utf8; |
114 | const char *filename_charset; | 115 | const char *filename_charset; |
@@ -121,13 +122,14 @@ GNUNET_GTK_from_filename_to_utf8 (gchar *filename) | |||
121 | if (is_UTF8) | 122 | if (is_UTF8) |
122 | str_utf8 = GNUNET_strdup (filename); | 123 | str_utf8 = GNUNET_strdup (filename); |
123 | else | 124 | else |
124 | str_utf8 = GNUNET_STRINGS_to_utf8 (filename, strlen (filename), filename_charset); | 125 | str_utf8 = |
126 | GNUNET_STRINGS_to_utf8 (filename, strlen (filename), filename_charset); | ||
125 | 127 | ||
126 | return str_utf8; | 128 | return str_utf8; |
127 | } | 129 | } |
128 | 130 | ||
129 | char * | 131 | char * |
130 | GNUNET_GTK_from_utf8_to_filename (gchar *str_utf8) | 132 | GNUNET_GTK_from_utf8_to_filename (gchar * str_utf8) |
131 | { | 133 | { |
132 | char *filename; | 134 | char *filename; |
133 | const char *filename_charset; | 135 | const char *filename_charset; |
@@ -140,13 +142,15 @@ GNUNET_GTK_from_utf8_to_filename (gchar *str_utf8) | |||
140 | if (is_UTF8) | 142 | if (is_UTF8) |
141 | filename = GNUNET_strdup (str_utf8); | 143 | filename = GNUNET_strdup (str_utf8); |
142 | else | 144 | else |
143 | filename = GNUNET_STRINGS_from_utf8 (str_utf8, strlen (str_utf8), filename_charset); | 145 | filename = |
146 | GNUNET_STRINGS_from_utf8 (str_utf8, strlen (str_utf8), | ||
147 | filename_charset); | ||
144 | 148 | ||
145 | return filename; | 149 | return filename; |
146 | } | 150 | } |
147 | 151 | ||
148 | char * | 152 | char * |
149 | GNUNET_GTK_from_loc_to_filename (gchar *str_loc) | 153 | GNUNET_GTK_from_loc_to_filename (gchar * str_loc) |
150 | { | 154 | { |
151 | char *filename; | 155 | char *filename; |
152 | const char *filename_charset; | 156 | const char *filename_charset; |
@@ -163,16 +167,19 @@ GNUNET_GTK_from_loc_to_filename (gchar *str_loc) | |||
163 | else if (is_filename_UTF8) | 167 | else if (is_filename_UTF8) |
164 | filename = GNUNET_STRINGS_to_utf8 (str_loc, strlen (str_loc), loc_charset); | 168 | filename = GNUNET_STRINGS_to_utf8 (str_loc, strlen (str_loc), loc_charset); |
165 | else if (is_loc_UTF8) | 169 | else if (is_loc_UTF8) |
166 | filename = GNUNET_STRINGS_from_utf8 (str_loc, strlen (str_loc), filename_charset); | 170 | filename = |
171 | GNUNET_STRINGS_from_utf8 (str_loc, strlen (str_loc), filename_charset); | ||
167 | else | 172 | else |
168 | /* Pray that iconv() knows these charsets */ | 173 | /* Pray that iconv() knows these charsets */ |
169 | filename = GNUNET_STRINGS_conv (str_loc, strlen (str_loc), loc_charset, filename_charset); | 174 | filename = |
175 | GNUNET_STRINGS_conv (str_loc, strlen (str_loc), loc_charset, | ||
176 | filename_charset); | ||
170 | 177 | ||
171 | return filename; | 178 | return filename; |
172 | } | 179 | } |
173 | 180 | ||
174 | char * | 181 | char * |
175 | GNUNET_GTK_from_filename_to_loc (gchar *filename) | 182 | GNUNET_GTK_from_filename_to_loc (gchar * filename) |
176 | { | 183 | { |
177 | char *str_loc; | 184 | char *str_loc; |
178 | const char *loc_charset; | 185 | const char *loc_charset; |
@@ -187,12 +194,16 @@ GNUNET_GTK_from_filename_to_loc (gchar *filename) | |||
187 | if (is_loc_UTF8 && is_filename_UTF8) | 194 | if (is_loc_UTF8 && is_filename_UTF8) |
188 | str_loc = GNUNET_strdup (filename); | 195 | str_loc = GNUNET_strdup (filename); |
189 | else if (is_loc_UTF8) | 196 | else if (is_loc_UTF8) |
190 | str_loc = GNUNET_STRINGS_to_utf8 (filename, strlen (filename), filename_charset); | 197 | str_loc = |
198 | GNUNET_STRINGS_to_utf8 (filename, strlen (filename), filename_charset); | ||
191 | else if (is_filename_UTF8) | 199 | else if (is_filename_UTF8) |
192 | str_loc = GNUNET_STRINGS_from_utf8 (filename, strlen (filename), loc_charset); | 200 | str_loc = |
201 | GNUNET_STRINGS_from_utf8 (filename, strlen (filename), loc_charset); | ||
193 | else | 202 | else |
194 | /* Pray that iconv() knows these charsets */ | 203 | /* Pray that iconv() knows these charsets */ |
195 | str_loc = GNUNET_STRINGS_conv (filename, strlen (filename), filename_charset, loc_charset); | 204 | str_loc = |
205 | GNUNET_STRINGS_conv (filename, strlen (filename), filename_charset, | ||
206 | loc_charset); | ||
196 | 207 | ||
197 | return str_loc; | 208 | return str_loc; |
198 | } | 209 | } |
@@ -201,20 +212,22 @@ GNUNET_GTK_from_filename_to_loc (gchar *filename) | |||
201 | * encoding, suitable to be given to CRT and/or GNUnet | 212 | * encoding, suitable to be given to CRT and/or GNUnet |
202 | */ | 213 | */ |
203 | char * | 214 | char * |
204 | GNUNET_GTK_filechooser_get_filename_loc (GtkFileChooser *fc) | 215 | GNUNET_GTK_filechooser_get_filename_loc (GtkFileChooser * fc) |
205 | { | 216 | { |
206 | char *filename_loc; | 217 | char *filename_loc; |
207 | gchar *filename = gtk_file_chooser_get_filename (fc); | 218 | gchar *filename = gtk_file_chooser_get_filename (fc); |
219 | |||
208 | filename_loc = GNUNET_GTK_from_filename_to_loc (filename); | 220 | filename_loc = GNUNET_GTK_from_filename_to_loc (filename); |
209 | g_free (filename); | 221 | g_free (filename); |
210 | return filename_loc; | 222 | return filename_loc; |
211 | } | 223 | } |
212 | 224 | ||
213 | gchar * | 225 | gchar * |
214 | GNUNET_GTK_filechooser_get_filename_utf8 (GtkFileChooser *fc) | 226 | GNUNET_GTK_filechooser_get_filename_utf8 (GtkFileChooser * fc) |
215 | { | 227 | { |
216 | char *filename_utf8; | 228 | char *filename_utf8; |
217 | gchar *filename = gtk_file_chooser_get_filename (fc); | 229 | gchar *filename = gtk_file_chooser_get_filename (fc); |
230 | |||
218 | filename_utf8 = GNUNET_GTK_from_filename_to_utf8 (filename); | 231 | filename_utf8 = GNUNET_GTK_from_filename_to_utf8 (filename); |
219 | g_free (filename); | 232 | g_free (filename); |
220 | return filename_utf8; | 233 | return filename_utf8; |