Mercurial > pidgin
diff libpurple/protocols/qq/char_conv.c @ 24146:ce94189f15ad
Flos Lonicerae <lonicerae(at)gmail.com>
* Merge lonicerae and ccpaging into trunk
author | SHiNE CsyFeK <csyfek@gmail.com> |
---|---|
date | Wed, 22 Oct 2008 14:52:26 +0000 |
parents | ec3f7d3e0445 |
children | b6f09c1c79ce |
line wrap: on
line diff
--- a/libpurple/protocols/qq/char_conv.c Wed Oct 22 14:49:38 2008 +0000 +++ b/libpurple/protocols/qq/char_conv.c Wed Oct 22 14:52:26 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.