comparison src/util.c @ 4458:a46c57f2d58b

[gaim-migrate @ 4733] (20:45:09) Trogdor: http://web.ics.purdue.edu/~eblanton/gaim/gaim-cvs-oscar-ssi-conv.diff (20:45:12) Trogdor: commit please (20:45:22) LSchiere: commit log? (20:45:48) Trogdor: Adds best-effort charset conversion to Oscar SSI aliases and group names. (20:45:55) Trogdor: oh (20:46:19) Trogdor: Also adds a gaim global function gaim_try_conv_to_utf8 () for attempting several logical encodings on a given string. (20:46:43) Trogdor: (which replaces the aptly named whatever_to_utf8) committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Wed, 29 Jan 2003 01:46:44 +0000
parents 5fb47ec9bfe4
children 62c1e5e656d0
comparison
equal deleted inserted replaced
4457:16e0c6826f23 4458:a46c57f2d58b
1277 GDK_MOD1_MASK, GTK_ACCEL_LOCKED); 1277 GDK_MOD1_MASK, GTK_ACCEL_LOCKED);
1278 */ 1278 */
1279 return menuitem; 1279 return menuitem;
1280 } 1280 }
1281 1281
1282 1282 char *gaim_try_conv_to_utf8(const char *str)
1283 1283 {
1284 1284 int converted;
1285 1285 char *utf8;
1286
1287 if (str == NULL) {
1288 return NULL;
1289 }
1290
1291 if (g_utf8_validate(str, -1, NULL)) {
1292 return g_strdup(str);
1293 }
1294
1295 utf8 = g_locale_to_utf8(str, -1, &converted, NULL, NULL);
1296 if (utf8 && converted == strlen (str)) {
1297 return(utf8);
1298 } else if (utf8) {
1299 g_free(utf8);
1300 }
1301
1302 utf8 = g_convert(str, -1, "UTF-8", "ISO-8859-15", &converted, NULL, NULL);
1303 if (utf8 && converted == strlen (str)) {
1304 return(utf8);
1305 } else if (utf8) {
1306 g_free(utf8);
1307 }
1308
1309 return(NULL);
1310 }