changeset 31351:ccd6a1da0d59

more unicode normalization
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Thu, 18 Nov 2010 23:07:34 +0900
parents 0462bec07414
children 29b4f2c52533
files libpurple/protocols/oscar/encoding.c
diffstat 1 files changed, 14 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/oscar/encoding.c	Wed Nov 10 11:41:51 2010 +0900
+++ b/libpurple/protocols/oscar/encoding.c	Thu Nov 18 23:07:34 2010 +0900
@@ -109,13 +109,13 @@
 oscar_utf8_try_convert(PurpleAccount *account, OscarData *od, const gchar *msg)
 {
 	const char *charset = NULL;
-	char *ret = NULL;
+	char *ret = NULL, *ret2 = NULL;
 
 	if (msg == NULL)
 		return NULL;
 
 	if (g_utf8_validate(msg, -1, NULL))
-		return g_strdup(msg);
+		return sanitize_utf(msg, -1, NULL);
 
 	if (od->icq)
 		charset = purple_account_get_string(account, "encoding", NULL);
@@ -126,7 +126,9 @@
 	if(!ret)
 		ret = purple_utf8_try_convert(msg);
 
-	return ret;
+	ret2 = sanitize_utf(ret, -1, NULL);
+	g_free(ret);
+	return ret2;
 }
 
 static gchar *
@@ -253,5 +255,13 @@
 	if (charsetstr != NULL) {
 		*charsetstr = msg_charset == AIM_CHARSET_ASCII ? "us-ascii" : "unicode-2-0";
 	}
-	return g_convert(msg, -1, msg_charset == AIM_CHARSET_ASCII ? "ASCII" : "UTF-16BE", "UTF-8", NULL, result_len, NULL);
+	if (msg_charset == AIM_CHARSET_ASCII) {
+		return g_convert(msg, -1, "ASCII", "UTF-8", NULL, result_len, NULL);
+	}
+	else {
+		char *ucs = NULL;
+		ucs = g_convert(msg, -1, "UTF-16BE", "UTF-8", NULL, result_len, NULL);
+		botch_ucs(ucs, *result_len);
+		return ucs;
+	}
 }