diff libpurple/protocols/qq/char_conv.c @ 24075:a95c7e71064c

2008.10.05 - ccpaging <ccpagint(at)gmail.com> * Add my uid into buddy list * Fixed a minor bug in qq_create_buddy. Not get new buddy's info. * There are 38 fields in protocol 2008, one more than 2005/2007. * The packet of Modifing buddy info is changed. Need sample to fix it.
author SHiNE CsyFeK <csyfek@gmail.com>
date Wed, 22 Oct 2008 14:48:46 +0000
parents df699d739b8f
children ec3f7d3e0445
line wrap: on
line diff
--- a/libpurple/protocols/qq/char_conv.c	Wed Oct 22 14:47:39 2008 +0000
+++ b/libpurple/protocols/qq/char_conv.c	Wed Oct 22 14:48:46 2008 +0000
@@ -98,7 +98,7 @@
 }
 
 /* convert a string from from_charset to to_charset, using g_convert */
-static gchar *_my_convert(const gchar *str, gssize len, const gchar *to_charset, const gchar *from_charset)
+static gchar *do_convert(const gchar *str, gssize len, const gchar *to_charset, const gchar *from_charset)
 {
 	GError *error = NULL;
 	gchar *ret;
@@ -128,14 +128,18 @@
  * returns the number of bytes read, return -1 if fatal error
  * the converted UTF-8 will be saved in ret
  */
-gint convert_as_pascal_string(guint8 *data, gchar **ret, const gchar *from_charset)
+gint qq_get_vstr(gchar **ret, const gchar *from_charset, guint8 *data)
 {
 	guint8 len;
 
 	g_return_val_if_fail(data != NULL && from_charset != NULL, -1);
 
 	len = data[0];
-	*ret = _my_convert((gchar *) (data + 1), (gssize) len, UTF8, from_charset);
+	if (len == 0) {
+		*ret = g_strdup("");
+		return 1;
+	}
+	*ret = do_convert((gchar *) (data + 1), (gssize) len, UTF8, from_charset);
 
 	return len + 1;
 }
@@ -214,15 +218,15 @@
 	return ret;
 }
 
-/* two convenience methods, using _my_convert */
+/* two convenience methods, using do_convert */
 gchar *utf8_to_qq(const gchar *str, const gchar *to_charset)
 {
-	return _my_convert(str, -1, to_charset, UTF8);
+	return do_convert(str, -1, to_charset, UTF8);
 }
 
 gchar *qq_to_utf8(const gchar *str, const gchar *from_charset)
 {
-	return _my_convert(str, -1, UTF8, from_charset);
+	return do_convert(str, -1, UTF8, from_charset);
 }
 
 /* QQ uses binary code for smiley, while purple uses strings.