changeset 10097:158950e7996d

[gaim-migrate @ 11119] I wrote this code with the assumption that iconv would fail if Gaim attempted to convert utf8 to an encoding that could not represent all the characters. This assumption is not true for all version of iconv (NetBSD 2.0, in this case). Pope not Calle of Flaxborough (notcalle) pointed this out and provided a fix. Thanks! committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Thu, 14 Oct 2004 03:44:42 +0000
parents 2923a6c59192
children fb4216714dac
files src/protocols/oscar/oscar.c
diffstat 1 files changed, 10 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/oscar/oscar.c	Thu Oct 14 03:25:40 2004 +0000
+++ b/src/protocols/oscar/oscar.c	Thu Oct 14 03:44:42 2004 +0000
@@ -498,10 +498,11 @@
 	const gchar *charsetstr;
 	gsize msglen;
 
+	*charset = oscar_charset_check(from);
+
 	/* Attempt to send as ASCII */
-	*msg = g_convert(from, strlen(from), "ASCII", "UTF-8", NULL, &msglen, NULL);
-	if (*msg != NULL) {
-		*charset = AIM_CHARSET_ASCII;
+	if (*charset == AIM_CHARSET_ASCII) {
+		*msg = g_convert(from, strlen(from), "ASCII", "UTF-8", NULL, &msglen, NULL);
 		*charsubset = 0x0000;
 		*msglen_int = msglen;
 		return;
@@ -532,6 +533,10 @@
 	if ((destsn != NULL) && aim_sn_is_icq(destsn))
 		charsetstr = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING);
 
+	/*
+	 * XXX - We need a way to only attempt to convert if we KNOW "from"
+	 * can be converted to "charsetstr"
+	 */
 	*msg = g_convert(from, strlen(from), charsetstr, "UTF-8", NULL, &msglen, NULL);
 	if (*msg != NULL) {
 		*charset = AIM_CHARSET_CUSTOM;
@@ -5499,7 +5504,7 @@
 		aim_locate_setprofile(od->sess, NULL, "", 0, NULL, NULL, 0);
 		return;
 	}
-		
+
 	text_html = gaim_strdup_withhtml(text);
 	charset = oscar_charset_check(text_html);
 	if (charset == AIM_CHARSET_UNICODE) {
@@ -5616,7 +5621,7 @@
 		gaim_notify_warning(gc, NULL, _("Away message too long."), errstr);
 		g_free(errstr);
 	}
-	
+
 	g_free(text_html);
 
 	return;