changeset 25507:abc46fd562bd

- add nosuke's cp932 handling code.
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Mon, 11 Jun 2007 13:05:14 +0000
parents e7cc85ad9a6e
children e0add2aafeaf 2dca564c2465
files libpurple/protocols/irc/parse.c
diffstat 1 files changed, 13 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/irc/parse.c	Sun Jun 10 18:41:41 2007 +0000
+++ b/libpurple/protocols/irc/parse.c	Mon Jun 11 13:05:14 2007 +0000
@@ -242,6 +242,8 @@
 	gboolean iskana = FALSE;
 	char *pos = NULL;
 	gboolean irc_use_sosi, irc_use_8bit;
+	char *strtmp;
+	size_t strtmp_len;
 
 	enclist = purple_account_get_string(irc->account, "encoding", IRC_DEFAULT_CHARSET);
 	encodings = g_strsplit(enclist, ",", 2);
@@ -254,11 +256,13 @@
 		return g_strdup(string);
 	}
 
-	utf8 = g_convert(string, strlen(string), encodings[0], "UTF-8", NULL, NULL, &err);
+	strtmp  = (char *)sanitize_utf((unsigned char *)string, strlen(string), &strtmp_len);
+	utf8 = g_convert(strtmp, strlen(strtmp), encodings[0], "UTF-8", NULL, NULL, &err);
+
 	if (err) {
 		purple_debug(PURPLE_DEBUG_ERROR, "irc", "Send conversion error: %s\n", err->message);
 		purple_debug(PURPLE_DEBUG_ERROR, "irc", "Sending as UTF-8 instead of %s\n", encodings[0]);
-		utf8 = g_strdup(string);
+		utf8 = g_strdup(strtmp);
 		g_error_free(err);
 	}
 
@@ -321,6 +325,7 @@
 	}
 
 	g_strfreev(encodings);
+	g_free(strtmp);
 	return utf8;
 }
 
@@ -334,6 +339,8 @@
 	gboolean retry;
 	gsize in_len, out_len;
 	int conv_len;
+	char *strtmp;
+	size_t strtmp_len;
 
 	enclist = purple_account_get_string(irc->account, "encoding", IRC_DEFAULT_CHARSET);
 	encodings = g_strsplit(enclist, ",", -1);
@@ -464,8 +471,10 @@
 
 
 		if(utf8){
-			g_strfreev(encodings);
-			return utf8;
+			strtmp  = (char *)botch_utf((unsigned char *)utf8, strlen(utf8), &strtmp_len);
+ 			g_strfreev(encodings);
+			g_free(utf8);
+			return strtmp;
 		}
 	}
 	g_strfreev(encodings);