comparison src/protocols/oscar/oscar.c @ 8250:b248c1f4efbd

[gaim-migrate @ 8973] 1) Minor changes to the network listen code again. Tim, let me know if you have any other suggestions. 2) Changed how charsets are handled in oscar a tad bit. I think this should guarantee that Gaim doesn't crash when people send funky messages, or have funky away messages or really anything that is using a charset that isn't utf8, iso-8859-1, ucs-2be, or ascii. Ethan, this should fix the problem with that person's away message. Although, the message itself still looks kinda funky to me. The encoding is Windows-31J, which is apparently a valid iconv encoding? You would know more than I. 3) Fix the following crash: 1. IM yourself a message on AIM 2. Do NOT begin to type a second message, but instead hit CTRL+up committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Fri, 13 Feb 2004 05:37:12 +0000
parents e7524f4b4ed2
children 04a3210e2fba
comparison
equal deleted inserted replaced
8249:b51ed4506180 8250:b248c1f4efbd
373 return AIM_IMFLAGS_ISO_8859_1; 373 return AIM_IMFLAGS_ISO_8859_1;
374 } else if (!strcmp(encoding, "unicode-2-0")) { 374 } else if (!strcmp(encoding, "unicode-2-0")) {
375 return AIM_IMFLAGS_UNICODE; 375 return AIM_IMFLAGS_UNICODE;
376 } else { 376 } else {
377 gaim_debug(GAIM_DEBUG_WARNING, "oscar", 377 gaim_debug(GAIM_DEBUG_WARNING, "oscar",
378 "Unrecognized character encoding '%s', falling back to ASCII\n", encoding); 378 "Unrecognized character encoding '%s', attempting to convert to utf8 anyway\n", encoding);
379 return 0; 379 return 99;
380 } 380 }
381 } 381 }
382 382
383 gchar *oscar_encoding_to_utf8(const char *encoding, const char *text, int textlen) 383 gchar *oscar_encoding_to_utf8(const char *encoding, const char *text, int textlen)
384 { 384 {
385 gchar *utf8 = NULL; 385 gchar *utf8 = NULL;
386 int flags = oscar_encoding_parse(encoding); 386 int flags = oscar_encoding_parse(encoding);
387 387
388 switch (flags) { 388 switch (flags) {
389 case 0: 389 case 0:
390 utf8 = g_strndup(text, textlen); 390 utf8 = g_convert(text, textlen, "UTF-8", "UTF-8", NULL, NULL, NULL);
391 break; 391 break;
392 case AIM_IMFLAGS_ISO_8859_1: 392 case AIM_IMFLAGS_ISO_8859_1:
393 utf8 = g_convert(text, textlen, "UTF-8", "ISO-8859-1", NULL, NULL, NULL); 393 utf8 = g_convert(text, textlen, "UTF-8", "ISO-8859-1", NULL, NULL, NULL);
394 break; 394 break;
395 case AIM_IMFLAGS_UNICODE: 395 case AIM_IMFLAGS_UNICODE:
396 utf8 = g_convert(text, textlen, "UTF-8", "UCS-2BE", NULL, NULL, NULL); 396 utf8 = g_convert(text, textlen, "UTF-8", "UCS-2BE", NULL, NULL, NULL);
397 break;
398 case 99:
399 utf8 = g_convert(text, textlen, "UTF-8", encoding, NULL, NULL, NULL);
400 if (utf8 == NULL) {
401 utf8 = g_convert(text, textlen, "UTF-8", "UTF-8", NULL, NULL, NULL);
402 }
397 break; 403 break;
398 } 404 }
399 405
400 return utf8; 406 return utf8;
401 } 407 }