Re: how to set language for non-unicode text



Han wrote:
Sorry. Will just gtk-app-devel-list in future.

Looks like GTK indeed encoded the string in Unicode, although the
original string was not in Unicode.

(gdb) p song_name
$2 = 0x810e300 "¸»Ê¿É½ÏÂ"

(gdb) x/8 0x810e300
0x810e300:    0xbbc2b8c2      0xbfc28ac3      0xbdc289c3      0x82c38fc3
0x810e310:    0x00000000      0x00000011      0x656d614e      0x2e313300

The original string was in GB2312 (4 chinese characters that use 8
bytes).  Looks like GTK+ just treated it as ASCII and converted it
into Unicode (as I didn't tell GTK+ about the original encoding).

GTK+ expects everything you pass to be UTF-8, so it tried to interpret
it as UTF-8. And there's no way to change that.

  I
am trying to find a way to convert the string from GB2312 to UTF8
properly.
  

... which means that, indeed, you must convert your string to UTF-8.
g_convert can help you:

http://library.gnome.org/devel/glib/stable/glib-Character-Set-Conversion.html#g-convert

-- 
It's reassuring to know that if you behave strangely enough, society will
take full responsibility for you.

Eduardo M KALINOWSKI
eduardo kalinowski com br




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