Re: how to convert chinsese-character to utf8?

On Wed, 2003-09-24 at 02:51, yangxiaoli wrote:
> I use function g_locale_to_utf8() and g_convert() to convert Chinese-character to utf8,but got error message: Invalid byte sequence in conversion input. How to convert it to utf8?

You should call g_convert, with the src_encoding properly set to the
same type as the chinese character to convert.

Known chinese encodings are:
EUC-CN, GBK, GB18030, ISO-2022-CN

So, if the character is encoded in BIG5, the proper call is:

gchar* dest = g_convert (big5_str, -1, "BIG5", "UTF-8", NULL, NULL,

If the source string is in another encoding, then you can replace "BIG5"
with the other encoding's name.

(the last 3 arguments are for bytes_read, bytes_written, and an optional
error-code/msg return.)


    Jim Cape

    "It is literally true that, like Christianity, Socialism
     has conquered the world by defeating itself."
        -- Alexander Berkman, ABC of Anarchism

Attachment: signature.asc
Description: This is a digitally signed message part

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]