comparison libpurple/protocols/yahoo/util.c @ 27773:0f3a131d23da

- import nosuke's hash 244 patch and others to yahoo plugin - do not perform any conversion in sanitize_* if _WIN32 defined - suppress warning as much as possible - fix indentation
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Fri, 29 Feb 2008 17:56:13 +0000
parents 839cc551cad9
children acef4202e147
comparison
equal deleted inserted replaced
27772:839cc551cad9 27773:0f3a131d23da
111 */ 111 */
112 char *yahoo_string_encode(PurpleConnection *gc, const char *str, gboolean *utf8) 112 char *yahoo_string_encode(PurpleConnection *gc, const char *str, gboolean *utf8)
113 { 113 {
114 struct yahoo_data *yd = gc->proto_data; 114 struct yahoo_data *yd = gc->proto_data;
115 char *ret = NULL; 115 char *ret = NULL;
116 size_t newlen; 116 gsize newlen;
117 const char *to_codeset; 117 const char *to_codeset;
118 118
119 if (utf8 && *utf8) { 119 if (utf8 && *utf8) {
120 return botch_utf((gchar *)str, strlen((gchar *)str), &newlen); 120 return botch_utf((gchar *)str, strlen((gchar *)str), &newlen);
121 } 121 }
143 */ 143 */
144 char *yahoo_string_decode(PurpleConnection *gc, const char *str, gboolean utf8) 144 char *yahoo_string_decode(PurpleConnection *gc, const char *str, gboolean utf8)
145 { 145 {
146 struct yahoo_data *yd = gc->proto_data; 146 struct yahoo_data *yd = gc->proto_data;
147 char *ret, *tmp; 147 char *ret, *tmp;
148 char *from_codeset; 148 const char *from_codeset;
149 size_t newlen; 149 gsize newlen;
150 150
151 if (utf8) { 151 if (utf8) {
152 ret = sanitize_utf((gchar *)str, strlen((gchar *)str), &newlen); 152 ret = sanitize_utf((gchar *)str, strlen((gchar *)str), &newlen);
153 if (g_utf8_validate(ret, -1, NULL)) 153 if (g_utf8_validate(ret, -1, NULL))
154 return ret; 154 return ret;
157 if (yd->jp && !utf8) 157 if (yd->jp && !utf8)
158 from_codeset = "SHIFT_JIS"; 158 from_codeset = "SHIFT_JIS";
159 else 159 else
160 from_codeset = purple_account_get_string(purple_connection_get_account(gc), "local_charset", "ISO-8859-1"); 160 from_codeset = purple_account_get_string(purple_connection_get_account(gc), "local_charset", "ISO-8859-1");
161 161
162 /* yaz: it's a kind of voodoo to avoid malconversion of "~". */ 162 ret = g_convert_with_fallback(str, strlen(str), "UTF-8", from_codeset, NULL, NULL, NULL, NULL);
163 tmp = g_convert(str, strlen(str), "EUC-JP", from_codeset, NULL, NULL, NULL);
164 if(tmp) {
165 ret = g_convert(tmp, strlen(tmp), "UTF-8", "EUC-JP", NULL, NULL, NULL);
166 g_free(tmp);
167 } else {
168 ret = g_convert_with_fallback(str, strlen(str), "UTF-8", from_codeset, NULL, NULL, NULL, NULL);
169 }
170 163
171 if (ret){ 164 if (ret){
172 tmp = ret; 165 tmp = ret;
173 ret = sanitize_utf((gchar *)tmp, strlen((gchar *)tmp), &newlen); 166 ret = sanitize_utf((gchar *)tmp, strlen((gchar *)tmp), &newlen);
174 g_free(tmp); 167 g_free(tmp);