comparison src/protocols/oscar/oscar.c @ 3850:daf2cec08eac

[gaim-migrate @ 4002] " The current ISO-8859-1 detection in oscar.c for determining what character set to use for sending an IM is completely busted. I don't know what I was thinking when I wrote it. This patch fixes that." --Ethan Blanton (eblanton) committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Fri, 01 Nov 2002 21:18:52 +0000
parents 62f1fd706de6
children b5d7232c3e76
comparison
equal deleted inserted replaced
3849:a3093efd9027 3850:daf2cec08eac
1778 if (err) { 1778 if (err) {
1779 debug_printf("Unicode IM conversion: %s\n", err->message); 1779 debug_printf("Unicode IM conversion: %s\n", err->message);
1780 tmp = strdup(_("(There was an error receiving this message)")); 1780 tmp = strdup(_("(There was an error receiving this message)"));
1781 } 1781 }
1782 } else { 1782 } else {
1783 /* This will get executed for both AIM_IMFLAGS_UNICODE and 1783 /* This will get executed for both AIM_IMFLAGS_ISO_8859_1 and
1784 * unflagged messages, which are ASCII. That's OK because 1784 * unflagged messages, which are ASCII. That's OK because
1785 * ASCII is a strict subset of ISO-8859-1; this should 1785 * ASCII is a strict subset of ISO-8859-1; this should
1786 * help with compatibility with old, broken versions of 1786 * help with compatibility with old, broken versions of
1787 * gaim (everything before 0.60) and other broken clients 1787 * gaim (everything before 0.60) and other broken clients
1788 * that will happily send ISO-8859-1 without marking it as 1788 * that will happily send ISO-8859-1 without marking it as
1789 * such */ 1789 * such */
1790 if (args->icbmflags & AIM_IMFLAGS_ISO_8859_1) {
1791 debug_printf ("Received ISO-8859-1 IM\n");
1792 }
1790 tmp = g_convert(args->msg, args->msglen, "UTF-8", "ISO-8859-1", NULL, &convlen, &err); 1793 tmp = g_convert(args->msg, args->msglen, "UTF-8", "ISO-8859-1", NULL, &convlen, &err);
1791 if (err) { 1794 if (err) {
1792 debug_printf("ISO-8859-1 IM conversion: %s\n", err->message); 1795 debug_printf("ISO-8859-1 IM conversion: %s\n", err->message);
1793 tmp = strdup(_("(There was an error receiving this message)")); 1796 tmp = strdup(_("(There was an error receiving this message)"));
1794 } 1797 }
1798 }
1799
1800 if (args->icbmflags & AIM_IMFLAGS_CUSTOMCHARSET) {
1801 debug_printf ("Custom character set: %d %d\n", args->charset, args->charsubset);
1795 } 1802 }
1796 1803
1797 if (args->icbmflags & AIM_IMFLAGS_TYPINGNOT) { 1804 if (args->icbmflags & AIM_IMFLAGS_TYPINGNOT) {
1798 char *who = normalize(userinfo->sn); 1805 char *who = normalize(userinfo->sn);
1799 if (!g_hash_table_lookup(od->supports_tn, who)) 1806 if (!g_hash_table_lookup(od->supports_tn, who))
3421 i++; 3428 i++;
3422 } 3429 }
3423 while (message[i]) { 3430 while (message[i]) {
3424 /* ISO-8859-1 is 0x00-0xbf in the first byte 3431 /* ISO-8859-1 is 0x00-0xbf in the first byte
3425 * followed by 0xc0-0xc3 in the second */ 3432 * followed by 0xc0-0xc3 in the second */
3426 if ((unsigned char)message[i] < 0x80 || 3433 if ((unsigned char)message[i] < 0x80) {
3427 (((unsigned char)message[i] & 0xc0) == 0x80 &&
3428 ((unsigned char)message[i + 1] & 0xfc) == 0xc0)) {
3429 i++; 3434 i++;
3435 continue;
3436 } else if (((unsigned char)message[i] & 0xfc) == 0xc0 &&
3437 ((unsigned char)message[i + 1] & 0xc0) == 0x80) {
3438 i += 2;
3430 continue; 3439 continue;
3431 } 3440 }
3432 args.flags ^= AIM_IMFLAGS_ISO_8859_1; 3441 args.flags ^= AIM_IMFLAGS_ISO_8859_1;
3433 args.flags |= AIM_IMFLAGS_UNICODE; 3442 args.flags |= AIM_IMFLAGS_UNICODE;
3434 break; 3443 break;
3435 } 3444 }
3436 if (args.flags & AIM_IMFLAGS_UNICODE) { 3445 if (args.flags & AIM_IMFLAGS_UNICODE) {
3446 debug_printf ("Sending Unicode IM\n");
3437 args.msg = g_convert(message, len, "UCS-2BE", "UTF-8", NULL, &len, &err); 3447 args.msg = g_convert(message, len, "UCS-2BE", "UTF-8", NULL, &len, &err);
3438 if (err) { 3448 if (err) {
3439 debug_printf("Error converting a unicode message: %s\n", err->message); 3449 debug_printf("Error converting a unicode message: %s\n", err->message);
3440 debug_printf("This really shouldn't happen!\n"); 3450 debug_printf("This really shouldn't happen!\n");
3441 /* We really shouldn't try to send the 3451 /* We really shouldn't try to send the
3442 * IM now, but I'm not sure what to do */ 3452 * IM now, but I'm not sure what to do */
3443 } 3453 }
3444 } else if (args.flags & AIM_IMFLAGS_UNICODE) { 3454 } else if (args.flags & AIM_IMFLAGS_ISO_8859_1) {
3455 debug_printf ("Sending ISO-8859-1 IM\n");
3445 args.msg = g_convert(message, len, "ISO-8859-1", "UTF-8", NULL, &len, &err); 3456 args.msg = g_convert(message, len, "ISO-8859-1", "UTF-8", NULL, &len, &err);
3446 if (err) { 3457 if (err) {
3447 debug_printf("conversion error: %s\n", err->message); 3458 debug_printf("conversion error: %s\n", err->message);
3448 debug_printf("Someone tell Ethan his 8859-1 detection is wrong\n"); 3459 debug_printf("Someone tell Ethan his 8859-1 detection is wrong\n");
3449 args.flags ^= AIM_IMFLAGS_ISO_8859_1 | AIM_IMFLAGS_UNICODE; 3460 args.flags ^= AIM_IMFLAGS_ISO_8859_1 | AIM_IMFLAGS_UNICODE;