Mercurial > pidgin.yaz
diff libpurple/protocols/yahoo/util.c @ 27876:5c76f76ee9db
propagate from branch 'im.pidgin.pidgin' (head 4e2880e0b1b33a1395280db14803f92cc93843de)
to branch 'im.pidgin.pidgin.yaz' (head c1a301a610acc031ca4edb7bead93fb218cbd78f)
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Fri, 05 Sep 2008 10:01:57 +0000 |
parents | 18a1f0fe5f40 fcd28c88459b |
children | 462a509fb2ad |
line wrap: on
line diff
--- a/libpurple/protocols/yahoo/util.c Fri Sep 05 09:30:00 2008 +0000 +++ b/libpurple/protocols/yahoo/util.c Fri Sep 05 10:01:57 2008 +0000 @@ -29,6 +29,7 @@ #include "prpl.h" #include "yahoo.h" +#include "util.h" #include <string.h> @@ -119,14 +120,13 @@ char *yahoo_string_encode(PurpleConnection *gc, const char *str, gboolean *utf8) { struct yahoo_data *yd = gc->proto_data; - char *ret; + char *ret = NULL; + gsize newlen; const char *to_codeset; - if (yd->jp) - return g_strdup(str); - - if (utf8 && *utf8) /* FIXME: maybe don't use utf8 if it'll fit in latin1 */ - return g_strdup(str); + if (utf8 && *utf8) { + return botch_utf((gchar *)str, strlen((gchar *)str), &newlen); + } to_codeset = purple_account_get_string(purple_connection_get_account(gc), "local_charset", "ISO-8859-1"); ret = g_convert_with_fallback(str, -1, to_codeset, "UTF-8", "?", NULL, NULL, NULL); @@ -148,23 +148,29 @@ char *yahoo_string_decode(PurpleConnection *gc, const char *str, gboolean utf8) { struct yahoo_data *yd = gc->proto_data; - char *ret; + char *ret, *tmp; const char *from_codeset; + gsize newlen; if (utf8) { - if (g_utf8_validate(str, -1, NULL)) - return g_strdup(str); + ret = sanitize_utf((gchar *)str, strlen((gchar *)str), &newlen); + if (g_utf8_validate(ret, -1, NULL)) + return ret; } - if (yd->jp) + if (yd->jp && !utf8) from_codeset = "SHIFT_JIS"; else from_codeset = purple_account_get_string(purple_connection_get_account(gc), "local_charset", "ISO-8859-1"); ret = g_convert_with_fallback(str, -1, "UTF-8", from_codeset, NULL, NULL, NULL, NULL); - if (ret) + if (ret) { + tmp = ret; + ret = sanitize_utf((gchar *)tmp, strlen((gchar *)tmp), &newlen); + g_free(tmp); return ret; + } else return g_strdup(""); }