changeset 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 a3093efd9027
children 80873188a634
files src/protocols/oscar/oscar.c
diffstat 1 files changed, 16 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/oscar/oscar.c	Fri Nov 01 20:35:12 2002 +0000
+++ b/src/protocols/oscar/oscar.c	Fri Nov 01 21:18:52 2002 +0000
@@ -1780,13 +1780,16 @@
 			tmp = strdup(_("(There was an error receiving this message)"));
 		}
 	} else {
-		/* This will get executed for both AIM_IMFLAGS_UNICODE and
+		/* This will get executed for both AIM_IMFLAGS_ISO_8859_1 and
 		 * unflagged messages, which are ASCII.  That's OK because
 		 * ASCII is a strict subset of ISO-8859-1; this should
 		 * help with compatibility with old, broken versions of
 		 * gaim (everything before 0.60) and other broken clients
 		 * that will happily send ISO-8859-1 without marking it as
 		 * such */
+		if (args->icbmflags & AIM_IMFLAGS_ISO_8859_1) {
+			debug_printf ("Received ISO-8859-1 IM\n");
+		}
 		tmp = g_convert(args->msg, args->msglen, "UTF-8", "ISO-8859-1", NULL, &convlen, &err);
 		if (err) {
 			debug_printf("ISO-8859-1 IM conversion: %s\n", err->message);
@@ -1794,6 +1797,10 @@
 		}
 	}
 
+	if (args->icbmflags & AIM_IMFLAGS_CUSTOMCHARSET) {
+		debug_printf ("Custom character set: %d %d\n", args->charset, args->charsubset);
+	}
+
 	if (args->icbmflags & AIM_IMFLAGS_TYPINGNOT) {
 		char *who = normalize(userinfo->sn);
 		if (!g_hash_table_lookup(od->supports_tn, who))
@@ -3423,17 +3430,20 @@
 		while (message[i]) {
 			/* ISO-8859-1 is 0x00-0xbf in the first byte
 			 * followed by 0xc0-0xc3 in the second */
-			if ((unsigned char)message[i] < 0x80 || 
-			    (((unsigned char)message[i] & 0xc0) == 0x80 &&
-			     ((unsigned char)message[i + 1] & 0xfc) == 0xc0)) {
+			if ((unsigned char)message[i] < 0x80) {
 				i++;
 				continue;
+			} else if (((unsigned char)message[i] & 0xfc) == 0xc0 &&
+				   ((unsigned char)message[i + 1] & 0xc0) == 0x80) {
+				i += 2;
+				continue;
 			}
 			args.flags ^= AIM_IMFLAGS_ISO_8859_1;
 			args.flags |= AIM_IMFLAGS_UNICODE;
 			break;
 		}
 		if (args.flags & AIM_IMFLAGS_UNICODE) {
+			debug_printf ("Sending Unicode IM\n");
 			args.msg = g_convert(message, len, "UCS-2BE", "UTF-8", NULL, &len, &err);
 			if (err) {
 				debug_printf("Error converting a unicode message: %s\n", err->message);
@@ -3441,7 +3451,8 @@
 				/* We really shouldn't try to send the
 				 * IM now, but I'm not sure what to do */
 			}
-		} else if (args.flags & AIM_IMFLAGS_UNICODE) {
+		} else if (args.flags & AIM_IMFLAGS_ISO_8859_1) {
+			debug_printf ("Sending ISO-8859-1 IM\n");
 			args.msg = g_convert(message, len, "ISO-8859-1", "UTF-8", NULL, &len, &err);
 			if (err) {
 				debug_printf("conversion error: %s\n", err->message);