[英]GLib convert GString from UTF-8 to UTF-16/32 possible?
The GLib provides the struct GString which is encoded in UTF-8. GLib提供了以UTF-8编码的GString结构。
I know there are functions to convert a single gchar (UTF-8) to gunicode (UTF-32) or gunicode2 (UTF-16). 我知道有一些功能可以将单个gchar (UTF-8)转换为gunicode (UTF-32)或gunicode2 (UTF-16)。
But if I want to convert a complete GString into UTF-16/UTF-32, is this possible? 但是,如果我想将完整的GString转换为UTF-16 / UTF-32,这可能吗?
If not, I don't see the point in storing the majority of text in UTF-8 strings but you can only convert single chars into UTF-16/UTF-32 and are forced to use gunicode-arrays, when GString encapsulated those nasty arrays. 如果没有,我看不到将大多数文本存储在UTF-8字符串中的意义,但是当GString封装那些讨厌的字符时,您只能将单个字符转换为UTF-16 / UTF-32并被迫使用gunicode-arrays阵列。 And you wouldn't be able to use all the string functions provided by the glib on your UTF-16/UTF-32 arrays.
而且您将无法在UTF-16 / UTF-32阵列上使用glib提供的所有字符串函数。
GLib provides several Character Set Conversion functions. GLib提供了几种字符集转换功能。 If you're confused about them not taking a
GString
, you can get at the underlying pointer and length using the str
and len
fields. 如果您对他们不使用
GString
感到困惑,则可以使用str
和len
字段获取基础指针和长度。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.