libpurple/protocols/qq/char_conv.c

changeset 23950
a974649cdb89
parent 23212
a39a33c79a3f
child 24019
c0801ae3c886
equal deleted inserted replaced
23949:9ec519c1b341 23950:a974649cdb89
35 #define UTF8 "UTF-8" 35 #define UTF8 "UTF-8"
36 #define QQ_CHARSET_ZH_CN "GB18030" 36 #define QQ_CHARSET_ZH_CN "GB18030"
37 #define QQ_CHARSET_ENG "ISO-8859-1" 37 #define QQ_CHARSET_ENG "ISO-8859-1"
38 38
39 #define QQ_NULL_MSG "(NULL)" /* return this if conversion fails */ 39 #define QQ_NULL_MSG "(NULL)" /* return this if conversion fails */
40 #define QQ_NULL_SMILEY "(SM)" /* return this if smiley conversion fails */ 40 #define QQ_NULL_SMILEY "(Broken)" /* return this if smiley conversion fails */
41 41
42 const gchar qq_smiley_map[QQ_SMILEY_AMOUNT] = { 42 const gchar qq_smiley_map[QQ_SMILEY_AMOUNT] = {
43 0x41, 0x43, 0x42, 0x44, 0x45, 0x46, 0x47, 0x48, 43 0x41, 0x43, 0x42, 0x44, 0x45, 0x46, 0x47, 0x48,
44 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x73, 44 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x73,
45 0x74, 0x75, 0x76, 0x77, 0x8a, 0x8b, 0x8c, 0x8d, 45 0x74, 0x75, 0x76, 0x77, 0x8a, 0x8b, 0x8c, 0x8d,
111 if (error == NULL) { 111 if (error == NULL) {
112 return ret; /* conversion is OK */ 112 return ret; /* conversion is OK */
113 } 113 }
114 114
115 /* conversion error */ 115 /* conversion error */
116 purple_debug(PURPLE_DEBUG_ERROR, "QQ", "%s\n", error->message); 116 purple_debug(PURPLE_DEBUG_ERROR, "QQ_CONVERT", "%s\n", error->message);
117 117
118 qq_hex_dump(PURPLE_DEBUG_WARNING, "QQ", 118 qq_hex_dump(PURPLE_DEBUG_WARNING, "QQ_CONVERT",
119 (guint8 *) str, (len == -1) ? strlen(str) : len, 119 (guint8 *) str, (len == -1) ? strlen(str) : len,
120 "Dump failed text"); 120 "Dump failed text");
121 121
122 g_error_free(error); 122 g_error_free(error);
123 return g_strdup(QQ_NULL_MSG); 123 return g_strdup(QQ_NULL_MSG);
149 guint16 charset_code; 149 guint16 charset_code;
150 gchar *font_name, *color_code, *msg_utf8, *tmp, *ret; 150 gchar *font_name, *color_code, *msg_utf8, *tmp, *ret;
151 gint bytes = 0; 151 gint bytes = 0;
152 152
153 /* checked qq_show_packet OK */ 153 /* checked qq_show_packet OK */
154 qq_show_packet("QQ_MESG recv for font style", data, len); 154 /* qq_show_packet("QQ_MESG recv for font style", data, len); */
155 155
156 bytes += qq_get8(&font_attr, data + bytes); 156 bytes += qq_get8(&font_attr, data + bytes);
157 bytes += qq_getdata(color, 3, data + bytes); /* red,green,blue */ 157 bytes += qq_getdata(color, 3, data + bytes); /* red,green,blue */
158 color_code = g_strdup_printf("#%02x%02x%02x", color[0], color[1], color[2]); 158 color_code = g_strdup_printf("#%02x%02x%02x", color[0], color[1], color[2]);
159 159
229 gint index; 229 gint index;
230 gchar qq_smiley, *cur_seg, **segments, *ret; 230 gchar qq_smiley, *cur_seg, **segments, *ret;
231 GString *converted; 231 GString *converted;
232 232
233 converted = g_string_new(""); 233 converted = g_string_new("");
234 segments = split_data((guint8 *) text, strlen(text), "\x14", 0); 234 segments = split_data((guint8 *) text, strlen(text), "\x14\x15", 0);
235 g_string_append(converted, segments[0]); 235 g_string_append(converted, segments[0]);
236 236
237 while ((*(++segments)) != NULL) { 237 while ((*(++segments)) != NULL) {
238 cur_seg = *segments; 238 cur_seg = *segments;
239 qq_smiley = cur_seg[0]; 239 qq_smiley = cur_seg[0];
284 if (str == NULL) { 284 if (str == NULL) {
285 return; 285 return;
286 } 286 }
287 287
288 for (temp = str; *temp != 0; temp++) { 288 for (temp = str; *temp != 0; temp++) {
289 if (*temp == '\r' || *temp == '\n') *temp = 0x20; 289 if (*temp == '\r' || *temp == '\n') *temp = ' ';
290 } 290 }
291 g_strstrip(str); 291 g_strstrip(str);
292 } 292 }
293 293
294 294

mercurial