diff 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
line wrap: on
line diff
--- a/src/protocols/oscar/oscar.c	Thu Feb 12 23:51:39 2004 +0000
+++ b/src/protocols/oscar/oscar.c	Fri Feb 13 05:37:12 2004 +0000
@@ -375,8 +375,8 @@
 		return AIM_IMFLAGS_UNICODE;
 	} else {
 		gaim_debug(GAIM_DEBUG_WARNING, "oscar",
-				   "Unrecognized character encoding '%s', falling back to ASCII\n", encoding);
-		return 0;
+				   "Unrecognized character encoding '%s', attempting to convert to utf8 anyway\n", encoding);
+		return 99;
 	}
 }
 
@@ -387,7 +387,7 @@
 
 	switch (flags) {
 	case 0:
-		utf8 = g_strndup(text, textlen);
+		utf8 = g_convert(text, textlen, "UTF-8", "UTF-8", NULL, NULL, NULL);
 		break;
 	case AIM_IMFLAGS_ISO_8859_1:
 		utf8 = g_convert(text, textlen, "UTF-8", "ISO-8859-1", NULL, NULL, NULL);
@@ -395,6 +395,12 @@
 	case AIM_IMFLAGS_UNICODE:
 		utf8 = g_convert(text, textlen, "UTF-8", "UCS-2BE", NULL, NULL, NULL);
 		break;
+	case 99:
+		utf8 = g_convert(text, textlen, "UTF-8", encoding, NULL, NULL, NULL);
+		if (utf8 == NULL) {
+			utf8 = g_convert(text, textlen, "UTF-8", "UTF-8", NULL, NULL, NULL);
+		}
+		break;
 	}
 
 	return utf8;