comparison src/protocols/yahoo/util.c @ 9164:76125b842b23

[gaim-migrate @ 9949] This is proper yahoo japan support. Technically it worked before, but you had to know the yahoo japan server, and typing in nonascii didn't work. The account options are kind of ugly. Eventually Chip is going to replace the check box with something more like a dropdown thingy, that automaticly hides the settings that aren't used (Pager Host vs. Japan Pager Host, etc) But it's not too bad now. And I think I orignally wrote this patch for 0.64 or something, so I got tired of waiting. committer: Tailor Script <tailor@pidgin.im>
author Tim Ringenbach <marv@pidgin.im>
date Wed, 02 Jun 2004 03:02:50 +0000
parents eb3c59b0a16c
children 34bce9529cf4
comparison
equal deleted inserted replaced
9163:8d22bc97b7be 9164:76125b842b23
42 * it is not dereferenced. 42 * it is not dereferenced.
43 * @return The g_malloced string in the appropriate encoding. 43 * @return The g_malloced string in the appropriate encoding.
44 */ 44 */
45 char *yahoo_string_encode(GaimConnection *gc, const char *str, gboolean *utf8) 45 char *yahoo_string_encode(GaimConnection *gc, const char *str, gboolean *utf8)
46 { 46 {
47 struct yahoo_data *yd = gc->proto_data;
47 char *ret; 48 char *ret;
48 char *to_codeset; 49 char *to_codeset;
49 50
51 if (yd->jp && utf8 && *utf8)
52 *utf8 = FALSE;
53
50 if (utf8 && *utf8) /* FIXME: maybe don't use utf8 if it'll fit in latin1 */ 54 if (utf8 && *utf8) /* FIXME: maybe don't use utf8 if it'll fit in latin1 */
51 return g_strdup(str); 55 return g_strdup(str);
52 56
53 to_codeset = "ISO-8859-1"; 57 if (yd->jp)
58 to_codeset = "SHIFT_JIS";
59 else
60 to_codeset = "ISO-8859-1";
54 61
55 ret = g_convert_with_fallback(str, strlen(str), to_codeset, "UTF-8", "?", NULL, NULL, NULL); 62 ret = g_convert_with_fallback(str, strlen(str), to_codeset, "UTF-8", "?", NULL, NULL, NULL);
56 if (ret) 63 if (ret)
57 return ret; 64 return ret;
58 else 65 else
67 * @param utf8 Did the server tell us it was supposed to be utf8? 74 * @param utf8 Did the server tell us it was supposed to be utf8?
68 * @return The decoded, utf-8 string, which must be g_free()'d. 75 * @return The decoded, utf-8 string, which must be g_free()'d.
69 */ 76 */
70 char *yahoo_string_decode(GaimConnection *gc, const char *str, gboolean utf8) 77 char *yahoo_string_decode(GaimConnection *gc, const char *str, gboolean utf8)
71 { 78 {
79 struct yahoo_data *yd = gc->proto_data;
72 char *ret; 80 char *ret;
73 char *from_codeset; 81 char *from_codeset;
74 82
75 if (utf8) { 83 if (utf8) {
76 if (g_utf8_validate(str, -1, NULL)) 84 if (g_utf8_validate(str, -1, NULL))
77 return g_strdup(str); 85 return g_strdup(str);
78 } 86 }
79 87
80 from_codeset = "ISO-8859-1"; 88 if (yd->jp)
89 from_codeset = "SHIFT_JIS";
90 else
91 from_codeset = "ISO-8859-1";
81 92
82 ret = g_convert_with_fallback(str, strlen(str), "UTF-8", from_codeset, NULL, NULL, NULL, NULL); 93 ret = g_convert_with_fallback(str, strlen(str), "UTF-8", from_codeset, NULL, NULL, NULL, NULL);
83 94
84 if (ret) 95 if (ret)
85 return ret; 96 return ret;