Mercurial > pidgin.yaz
diff libpurple/protocols/yahoo/util.c @ 25467:be098f796b32
yaz patch has been applied.
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Wed, 25 Apr 2007 07:57:26 +0000 |
parents | 8e61e7be988b |
children | 411b5a604a17 |
line wrap: on
line diff
--- a/libpurple/protocols/yahoo/util.c Wed Apr 25 07:51:56 2007 +0000 +++ b/libpurple/protocols/yahoo/util.c Wed Apr 25 07:57:26 2007 +0000 @@ -29,6 +29,7 @@ #include "prpl.h" #include "yahoo.h" +#include "util.h" #include <string.h> @@ -47,7 +48,8 @@ char *yahoo_string_encode(PurpleConnection *gc, const char *str, gboolean *utf8) { struct yahoo_data *yd = gc->proto_data; - char *ret; + char *ret, *strtmp; + int newlen; const char *to_codeset; if (yd->jp && utf8 && *utf8) @@ -61,7 +63,12 @@ else to_codeset = purple_account_get_string(purple_connection_get_account(gc), "local_charset", "ISO-8859-1"); - ret = g_convert_with_fallback(str, strlen(str), to_codeset, "UTF-8", "?", NULL, NULL, NULL); + strtmp = sanitize_utf((char *)str, strlen((char *)str), &newlen); + + ret = g_convert_with_fallback(strtmp, strlen(strtmp), to_codeset, "UTF-8", "?", NULL, NULL, NULL); + + g_free(strtmp); + if (ret) return ret; else @@ -79,8 +86,9 @@ char *yahoo_string_decode(PurpleConnection *gc, const char *str, gboolean utf8) { struct yahoo_data *yd = gc->proto_data; - char *ret; - const char *from_codeset; + char *ret, *tmp; + char *from_codeset; + int newlen; if (utf8) { if (g_utf8_validate(str, -1, NULL)) @@ -92,10 +100,21 @@ else from_codeset = purple_account_get_string(purple_connection_get_account(gc), "local_charset", "ISO-8859-1"); - ret = g_convert_with_fallback(str, strlen(str), "UTF-8", from_codeset, NULL, NULL, NULL, NULL); + /* yaz: it's a kind of voodoo to avoid malconversion of "~". */ + tmp = g_convert(str, strlen(str), "EUC-JP", from_codeset, NULL, NULL, NULL); + if(tmp) { + ret = g_convert(tmp, strlen(tmp), "UTF-8", "EUC-JP", NULL, NULL, NULL); + g_free(tmp); + } else { + ret = g_convert_with_fallback(str, strlen(str), "UTF-8", from_codeset, NULL, NULL, NULL, NULL); + } - if (ret) + if (ret){ + tmp = ret; + ret = botch_utf(ret, strlen(ret), &newlen); + g_free(tmp); return ret; + } else return g_strdup(""); }