--- gaim-0.68.orig/src/protocols/oscar/oscar.c
+++ gaim-0.68/src/protocols/oscar/oscar.c
@@ -2168,6 +2168,7 @@
 	GError *err = NULL;
 	struct buddyinfo *bi;
 	const char *iconfile;
+    const char *encoding = gaim_account_get_string(gaim_connection_get_account(gc), "encoding", NULL);
 
 	bi = g_hash_table_lookup(od->buddyinfo, normalize(userinfo->sn));
 	if (!bi) {
@@ -2237,10 +2238,13 @@
 
 		tmp = g_convert(args->msg, args->msglen, "UTF-8", "UCS-2BE", NULL, &convlen, &err);
 		if (err) {
-			gaim_debug(GAIM_DEBUG_INFO, "oscar",
-					   "Unicode IM conversion: %s\n", err->message);
-			tmp = strdup(_("(There was an error receiving this message)"));
-			g_error_free(err);
+            tmp = g_convert(args->msg, args->msglen, encoding, "UCS-2BE", NULL, &convlen, &err);
+            if(err){
+                gaim_debug(GAIM_DEBUG_INFO, "oscar",
+                           "Unicode IM conversion: %s\n", err->message);
+                tmp = strdup(_("(There was an error receiving this message)"));
+                g_error_free(err);
+            }
 		}
 	} else {
 		/* This will get executed for both AIM_IMFLAGS_ISO_8859_1 and
@@ -2252,15 +2256,19 @@
 		 * such */
 		if (args->icbmflags & AIM_IMFLAGS_ISO_8859_1)
 			gaim_debug(GAIM_DEBUG_INFO, "oscar",
-					   "Received ISO-8859-1 IM\n");
+				"Received Multilingual IM\n");
+        else
+            gaim_debug(GAIM_DEBUG_INFO, "oscar",
+				"Received non-ISO-8859-1 IM\n");
+
 
 		if (!args->msg || !args->msglen)
 			return 1;
 
-		tmp = g_convert(args->msg, args->msglen, "UTF-8", "ISO-8859-1", NULL, &convlen, &err);
+		tmp = g_convert(args->msg, args->msglen, "UTF-8", encoding, NULL, &convlen, &err);
 		if (err) {
 			gaim_debug(GAIM_DEBUG_INFO, "oscar",
-					   "ISO-8859-1 IM conversion: %s\n", err->message);
+					   "Multilingual IM conversion: %s\n", err->message);
 			tmp = strdup(_("(There was an error receiving this message)"));
 			g_error_free(err);
 		}
@@ -2553,6 +2561,7 @@
 	gchar **msg1, **msg2;
 	GError *err = NULL;
 	int i, numtoks;
+    const char *encoding = gaim_account_get_string(gaim_connection_get_account(gc), "encoding", NULL);
 
 	if (!args->type || !args->msg || !args->uin)
 		return 1;
@@ -2566,13 +2575,15 @@
 	msg2 = (gchar **)g_malloc((numtoks+1)*sizeof(gchar *));
 	for (i=0; msg1[i]; i++) {
 		strip_linefeed(msg1[i]);
-		msg2[i] = g_convert(msg1[i], strlen(msg1[i]), "UTF-8", "ISO-8859-1", NULL, NULL, &err);
-		if (err) {
-			gaim_debug(GAIM_DEBUG_ERROR, "oscar",
-					   "Error converting a string from ISO-8859-1 to "
-					   "UTF-8 in oscar ICBM channel 4 parsing\n");
-			g_error_free(err);
-		}
+        if(encoding){
+            msg2[i] = g_convert(msg1[i], strlen(msg1[i]), "UTF-8", encoding, NULL, NULL, &err);
+            if (err) {
+                gaim_debug(GAIM_DEBUG_ERROR, "oscar",
+                           "Error converting a string to "
+                           "UTF-8 in oscar ICBM channel 4 parsing\n");
+                g_error_free(err);
+            }
+        }
 	}
 	msg2[i] = NULL;
 
@@ -3163,6 +3174,7 @@
 	char *text_enc = NULL, *text = NULL, *utf8 = NULL;
 	int text_len;
 	const char *username = gaim_account_get_username(gaim_connection_get_account(gc));
+    const char *encoding = gaim_account_get_string(gaim_connection_get_account(gc), "encoding", NULL);
 
 	va_start(ap, fr);
 	info = va_arg(ap, aim_userinfo_t *);
@@ -3174,9 +3186,11 @@
 
 	if (text_len > 0) {
 		if (!(utf8 = oscar_encoding_to_utf8(text_enc, text, text_len))) {
-			utf8 = g_strdup(_("<i>Unable to display information because it was sent in an unknown encoding.</i>"));
-			gaim_debug(GAIM_DEBUG_ERROR, "oscar",
-					   "Encountered an unknown encoding while parsing userinfo\n");
+			if (encoding && !(utf8 = g_convert(text, text_len, "UTF-8", encoding, NULL, NULL, NULL))) {
+				utf8 = g_strdup(_("<i>Unable to display information because it was sent in an unknown encoding.</i>"));
+				gaim_debug(GAIM_DEBUG_ERROR, "oscar",
+						   "Encountered an unknown encoding while parsing userinfo\n");
+			}
 		}
 	}
 
@@ -3933,6 +3947,8 @@
 	return 1;
 }
 
+#define CONVERT_FROM_LOCALE(x) (encoding && (x) ? g_convert((x), strlen(x), "UTF-8", encoding, NULL, NULL, NULL) : (x))
+
 static int gaim_icqinfo(aim_session_t *sess, aim_frame_t *fr, ...)
 {
 	GaimConnection *gc = sess->aux_data;
@@ -3940,6 +3956,7 @@
 	gchar who[16];
 	va_list ap;
 	struct aim_icq_info *info;
+	const char *encoding = gaim_account_get_string(gaim_connection_get_account(gc), "encoding", NULL);
 
 	va_start(ap, fr);
 	info = va_arg(ap, struct aim_icq_info *);
@@ -3950,27 +3967,27 @@
 
 	g_snprintf(who, sizeof(who), "%u", info->uin);
 	buf = g_strdup_printf("<b>%s:</b> %s", _("UIN"), who);
-	if (info->nick && info->nick[0] && (utf8 = gaim_try_conv_to_utf8(info->nick))) {
+	if (info->nick && info->nick[0] && (utf8 = CONVERT_FROM_LOCALE(info->nick))) {
 		tmp = buf;  buf = g_strconcat(tmp, "\n<br><b>", _("Nick"), ":</b> ", utf8, NULL);  g_free(tmp); g_free(utf8);
 	}
-	if (info->first && info->first[0] && (utf8 = gaim_try_conv_to_utf8(info->first))) {
+	if (info->first && info->first[0] && (utf8 = CONVERT_FROM_LOCALE(info->first))) {
 		tmp = buf;  buf = g_strconcat(tmp, "\n<br><b>", _("First Name"), ":</b> ", utf8, NULL);  g_free(tmp); g_free(utf8);
 	}
-	if (info->last && info->last[0] && (utf8 = gaim_try_conv_to_utf8(info->last))) {
+	if (info->last && info->last[0] && (utf8 = CONVERT_FROM_LOCALE(info->last))) {
 		tmp = buf;  buf = g_strconcat(tmp, "\n<br><b>", _("Last Name"), ":</b> ", utf8, NULL);  g_free(tmp); g_free(utf8);
 	}
-	if (info->email && info->email[0] && (utf8 = gaim_try_conv_to_utf8(info->email))) {
+	if (info->email && info->email[0] && (utf8 = CONVERT_FROM_LOCALE(info->email))) {
 		tmp = buf;  buf = g_strconcat(tmp, "\n<br><b>", _("Email Address"), ":</b> <a href=\"mailto:", utf8, "\">", utf8, "</a>", NULL);  g_free(tmp); g_free(utf8);
 	}
 	if (info->numaddresses && info->email2) {
 		int i;
 		for (i = 0; i < info->numaddresses; i++) {
-			if (info->email2[i] && info->email2[i][0] && (utf8 = gaim_try_conv_to_utf8(info->email2[i]))) {
+			if (info->email2[i] && info->email2[i][0] && (utf8 = CONVERT_FROM_LOCALE(info->email2[i]))) {
 			tmp = buf;  buf = g_strconcat(tmp, "\n<br><b>", _("Email Address"), ":</b> <a href=\"mailto:", utf8, "\">", utf8, "</a>", NULL);  g_free(tmp); g_free(utf8);
 			}
 		}
 	}
-	if (info->mobile && info->mobile[0] && (utf8 = gaim_try_conv_to_utf8(info->mobile))) {
+	if (info->mobile && info->mobile[0] && (utf8 = CONVERT_FROM_LOCALE(info->mobile))) {
 		tmp = buf;  buf = g_strconcat(tmp, "\n<br><b>", _("Mobile Phone"), ":</b> ", utf8, NULL);  g_free(tmp); g_free(utf8);
 	}
 	if (info->gender) {
@@ -3990,57 +4007,57 @@
 		snprintf(age, sizeof(age), "%hhd", info->age);
 		tmp = buf;  buf = g_strconcat(tmp, "\n<br><b>", _("Age"), ":</b> ", age, NULL);  g_free(tmp);
 	}
-	if (info->personalwebpage && info->personalwebpage[0] && (utf8 = gaim_try_conv_to_utf8(info->personalwebpage))) {
+	if (info->personalwebpage && info->personalwebpage[0] && (utf8 = CONVERT_FROM_LOCALE(info->personalwebpage))) {
 		tmp = buf;  buf = g_strconcat(tmp, "\n<br><b>", _("Personal Web Page"), ":</b> <a href=\"", utf8, "\">", utf8, "</a>", NULL);  g_free(tmp); g_free(utf8);
 	}
-	if (info->info && info->info[0] && (utf8 = gaim_try_conv_to_utf8(info->info))) {
+	if (info->info && info->info[0] && (utf8 = CONVERT_FROM_LOCALE(info->info))) {
 		tmp = buf;  buf = g_strconcat(tmp, "<hr><b>", _("Additional Information"), ":</b><br>", utf8, NULL);  g_free(tmp); g_free(utf8);
 	}
 	tmp = buf;  buf = g_strconcat(tmp, "<hr>\n", NULL);  g_free(tmp);
 	if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) {
 		tmp = buf;  buf = g_strconcat(tmp, "<b>", _("Home Address"), ":</b>", NULL);  g_free(tmp);
-		if (info->homeaddr && info->homeaddr[0] && (utf8 = gaim_try_conv_to_utf8(info->homeaddr))) {
+		if (info->homeaddr && info->homeaddr[0] && (utf8 = CONVERT_FROM_LOCALE(info->homeaddr))) {
 			tmp = buf;  buf = g_strconcat(tmp, "\n<br><b>", _("Address"), ":</b> ", utf8, NULL);  g_free(tmp); g_free(utf8);
 		}
-		if (info->homecity && info->homecity[0] && (utf8 = gaim_try_conv_to_utf8(info->homecity))) {
+		if (info->homecity && info->homecity[0] && (utf8 = CONVERT_FROM_LOCALE(info->homecity))) {
 			tmp = buf;  buf = g_strconcat(tmp, "\n<br><b>", _("City"), ":</b> ", utf8,  NULL);  g_free(tmp); g_free(utf8);
 		}
-		if (info->homestate && info->homestate[0] && (utf8 = gaim_try_conv_to_utf8(info->homestate))) {
+		if (info->homestate && info->homestate[0] && (utf8 = CONVERT_FROM_LOCALE(info->homestate))) {
 			tmp = buf;  buf = g_strconcat(tmp, "\n<br><b>", _("State"), ":</b> ", utf8, NULL);  g_free(tmp); g_free(utf8);
 		}
-		if (info->homezip && info->homezip[0] && (utf8 = gaim_try_conv_to_utf8(info->homezip))) {
+		if (info->homezip && info->homezip[0] && (utf8 = CONVERT_FROM_LOCALE(info->homezip))) {
 			tmp = buf;  buf = g_strconcat(tmp, "\n<br><b>", _("Zip Code"), ":</b> ", utf8, NULL);  g_free(tmp); g_free(utf8);
 		}
 		tmp = buf; buf = g_strconcat(tmp, "\n<hr>\n", NULL); g_free(tmp);
 	}
 	if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) {
 		tmp = buf;  buf = g_strconcat(tmp, "<b>", _("Work Address"), ":</b>", NULL);  g_free(tmp);
-		if (info->workaddr && info->workaddr[0] && (utf8 = gaim_try_conv_to_utf8(info->workaddr))) {
+		if (info->workaddr && info->workaddr[0] && (utf8 = CONVERT_FROM_LOCALE(info->workaddr))) {
 			tmp = buf;  buf = g_strconcat(tmp, "\n<br><b>", _("Address"), ":</b> ", utf8, NULL);  g_free(tmp); g_free(utf8);
 		}
-		if (info->workcity && info->workcity[0] && (utf8 = gaim_try_conv_to_utf8(info->workcity))) {
+		if (info->workcity && info->workcity[0] && (utf8 = CONVERT_FROM_LOCALE(info->workcity))) {
 			tmp = buf;  buf = g_strconcat(tmp, "\n<br><b>", _("City"), ":</b> ", utf8, NULL);  g_free(tmp); g_free(utf8);
 		}
-		if (info->workstate && info->workstate[0] && (utf8 = gaim_try_conv_to_utf8(info->workstate))) {
+		if (info->workstate && info->workstate[0] && (utf8 = CONVERT_FROM_LOCALE(info->workstate))) {
 			tmp = buf;  buf = g_strconcat(tmp, "\n<br><b>", _("State"), ":</b> ", utf8, NULL);  g_free(tmp); g_free(utf8);
 		}
-		if (info->workzip && info->workzip[0] && (utf8 = gaim_try_conv_to_utf8(info->workzip))) {
+		if (info->workzip && info->workzip[0] && (utf8 = CONVERT_FROM_LOCALE(info->workzip))) {
 			tmp = buf;  buf = g_strconcat(tmp, "\n<br><b>", _("Zip Code"), ":</b> ", utf8, NULL);  g_free(tmp); g_free(utf8);
 		}
 		tmp = buf; buf = g_strconcat(tmp, "\n<hr>\n", NULL); g_free(tmp);
 	}
 	if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) {
 		tmp = buf;  buf = g_strconcat(tmp, "<b>", _("Work Information"), ":</b>", NULL);  g_free(tmp);
-		if (info->workcompany && info->workcompany[0] && (utf8 = gaim_try_conv_to_utf8(info->workcompany))) {
+		if (info->workcompany && info->workcompany[0] && (utf8 = CONVERT_FROM_LOCALE(info->workcompany))) {
 			tmp = buf;  buf = g_strconcat(tmp, "\n<br><b>", _("Company"), ":</b> ", utf8, NULL);  g_free(tmp); g_free(utf8);
 		}
-		if (info->workdivision && info->workdivision[0] && (utf8 = gaim_try_conv_to_utf8(info->workdivision))) {
+		if (info->workdivision && info->workdivision[0] && (utf8 = CONVERT_FROM_LOCALE(info->workdivision))) {
 			tmp = buf;  buf = g_strconcat(tmp, "\n<br><b>", _("Division"), ":</b> ", utf8, NULL);  g_free(tmp); g_free(utf8);
 		}
-		if (info->workposition && info->workposition[0] && (utf8 = gaim_try_conv_to_utf8(info->workposition))) {
+		if (info->workposition && info->workposition[0] && (utf8 = CONVERT_FROM_LOCALE(info->workposition))) {
 			tmp = buf;  buf = g_strconcat(tmp, "\n<br><b>", _("Position"), ":</b> ", utf8, NULL);  g_free(tmp); g_free(utf8);
 		}
-		if (info->workwebpage && info->workwebpage[0] && (utf8 = gaim_try_conv_to_utf8(info->workwebpage))) {
+		if (info->workwebpage && info->workwebpage[0] && (utf8 = CONVERT_FROM_LOCALE(info->workwebpage))) {
 			tmp = buf;  buf = g_strconcat(tmp, "\n<br><b>", _("Web Page"), ":</b> <a href=\"", utf8, "\">", utf8, "</a>", NULL);  g_free(tmp); g_free(utf8);
 		}
 		tmp = buf; buf = g_strconcat(tmp, "\n<hr>\n", NULL); g_free(tmp);
@@ -4055,6 +4072,7 @@
 static int gaim_icqalias(aim_session_t *sess, aim_frame_t *fr, ...)
 {
 	GaimConnection *gc = sess->aux_data;
+	const char *encoding = gaim_account_get_string(gaim_connection_get_account(gc), "encoding", NULL);
 	gchar who[16], *utf8;
 	struct buddy *b;
 	va_list ap;
@@ -4064,7 +4082,7 @@
 	info = va_arg(ap, struct aim_icq_info *);
 	va_end(ap);
 
-	if (info->uin && info->nick && info->nick[0] && (utf8 = gaim_try_conv_to_utf8(info->nick))) {
+	if (info->uin && info->nick && info->nick[0] && (utf8 = CONVERT_FROM_LOCALE(info->nick))) {
 		g_snprintf(who, sizeof(who), "%u", info->uin);
 		serv_got_alias(gc, who, utf8);
 		if ((b = gaim_find_buddy(gc->account, who))) {
@@ -4265,6 +4283,7 @@
 	int ret = 0;
 	GError *err = NULL;
 	const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc));
+    const char *encoding = gaim_account_get_string(gaim_connection_get_account(gc), "encoding", NULL);
 	char *tmpmsg = NULL;
 
 	if (dim && dim->connected) {
@@ -4349,18 +4368,33 @@
 
 		args.flags |= oscar_encoding_check(tmpmsg);
 		if (args.flags & AIM_IMFLAGS_UNICODE) {
-			gaim_debug(GAIM_DEBUG_INFO, "oscar", "Sending Unicode IM\n");
-			args.charset = 0x0002;
-			args.charsubset = 0x0000;
-			args.msg = g_convert(tmpmsg, len, "UCS-2BE", "UTF-8", NULL, &len, &err);
-			if (err) {
-				gaim_debug(GAIM_DEBUG_ERROR, "oscar",
-						   "Error converting a unicode message: %s\n", err->message);
-				gaim_debug(GAIM_DEBUG_ERROR, "oscar",
-						   "This really shouldn't happen!\n");
-				/* We really shouldn't try to send the
-				 * IM now, but I'm not sure what to do */
-				g_error_free(err);
+			if (bi->caps & AIM_CAPS_ICQUTF8) {
+				gaim_debug(GAIM_DEBUG_INFO, "oscar", "Sending Unicode IM\n");
+				args.charset = 0x0002;
+				args.charsubset = 0x0000;
+				args.msg = g_convert(tmpmsg, len, "UCS-2BE", "UTF-8", NULL, &len, &err);
+				if (err) {
+					gaim_debug(GAIM_DEBUG_ERROR, "oscar",
+							   "Error converting a unicode message: %s\n", err->message);
+					gaim_debug(GAIM_DEBUG_ERROR, "oscar",
+							   "This really shouldn't happen!\n");
+					/* We really shouldn't try to send the
+					 * IM now, but I'm not sure what to do */
+					g_error_free(err);
+				}
+			}
+			else{
+				gaim_debug(GAIM_DEBUG_ERROR, "oscar", "Client does not understand UTF-8\n");
+				args.charset = 0x0000;
+				args.charsubset = 0x0000;
+                if(encoding){
+                    args.msg = g_convert(message, len, encoding, "UTF-8", NULL, &len, &err);
+                    if (err) {
+                        gaim_debug(GAIM_DEBUG_ERROR, "oscar",
+                                "Error converting a nonunicode message: %s\n", err->message);
+                        g_error_free(err);
+                    }
+                }
 			}
 		} else if (args.flags & AIM_IMFLAGS_ISO_8859_1) {
 			gaim_debug(GAIM_DEBUG_INFO, "oscar",
@@ -4819,6 +4853,7 @@
 
 static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) {
 	GaimConnection *gc = sess->aux_data;
+	const char *encoding = gaim_account_get_string(gaim_connection_get_account(gc), "encoding", NULL);
 	GaimAccount *account = gaim_connection_get_account(gc);
 	struct oscar_data *od = (struct oscar_data *)gc->proto_data;
 	struct aim_ssi_item *curitem;
@@ -4846,9 +4881,9 @@
 			case 0x0000: { /* Buddy */
 				if (curitem->name) {
 					char *gname = aim_ssi_itemlist_findparentname(sess->ssi.local, curitem->name);
-					char *gname_utf8 = gaim_try_conv_to_utf8(gname);
+					char *gname_utf8 = CONVERT_FROM_LOCALE(gname);
 					char *alias = aim_ssi_getalias(sess->ssi.local, gname, curitem->name);
-					char *alias_utf8 = gaim_try_conv_to_utf8(alias);
+					char *alias_utf8 = CONVERT_FROM_LOCALE(alias);
 					struct buddy *buddy = gaim_find_buddy(gc->account, curitem->name);
 					/* Should gname be freed here? -- elb */
 					/* Not with the current code, but that might be cleaner -- med */
@@ -6343,6 +6378,10 @@
 	prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,
 											   option);
 
+	option = gaim_account_option_string_new(_("Encoding(ICQ)"), "encoding", "windows-1251");
+	prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,
+											   option);
+
 	my_protocol = plugin;
 }
 
