- 论坛徽章:
- 0
|
g_locale_to_utf8 ()
gchar* g_locale_to_utf8 (const gchar *opsysstring,
gssize len,
gsize *bytes_read,
gsize *bytes_written,
GError **error);
Converts a string which is in the encoding used for strings by the C runtime (usually the same as that used by the operating system) in the current locale into a UTF-8 string.
opsysstring :
a string in the encoding of the current locale. On Windows this means the system codepage.
len :
the length of the string, or -1 if the string is nul-terminated[1].
bytes_read :
location to store the number of bytes in the input string that were successfully converted, or NULL. Even if the conversion was successful, this may be less than len if there were partial characters at the end of the input. If the error G_CONVERT_ERROR_ILLEGAL_SEQUENCE occurs, the value stored will the byte offset after the last valid input sequence.
bytes_written :
the number of bytes stored in the output buffer (not including the terminating nul).
error :
location to store the error occuring, or NULL to ignore errors. Any of the errors in GConvertError may occur.
Returns :
The converted string, or NULL on an error.
g_locale_to_utf8函数的返回值才是utf8格式的编码,你在打印的时候是正常的,是因为打印的仍然是当前语言环境下面的编码,不是utf8的编码。
改为:
char * test = g_locale_to_utf8(animaltype, -1, NULL, NULL, NULL);
gtk_entry_set_text(GTK_ENTRY(etyType),test); |
|