简体   繁体   English

GLib可以将GString从UTF-8转换为UTF-16 / 32吗?

[英]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感到困惑,则可以使用strlen字段获取基础指针和长度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 Windows 和 Linux 下将 UTF-16 转换为 UTF-8,在 Z0D61F8370CAD1D412F80ZB84D1 - Convert UTF-16 to UTF-8 under Windows and Linux, in C 如何在 C 中将 UTF-8 与 UTF-16 相互转换? - How do I convert UTF-8 to/from UTF-16 in C? C中的UTF-16到UTF-8 - UTF-16 to UTF-8 in C 如果源代码是 UTF-8 编码在 win32 中,如何显示 UTF-16 const 字符串? - How to display UTF-16 const strings if the source code is UTF-8 encoded in win32? libiconv:在 UTF-8/UTF-16/UTF-32 之间转换时安全估计目标字节长度? - libiconv: Safe estimation of target bytes-length when converting between UTF-8/UTF-16/UTF-32? 适用于 Windows 的 UTF-8 到 UTF-16 API 包装器库? - UTF-8 to UTF-16 API wrapper libraries for Windows? 在Windows上使用C中的WideCharToMultiByte将UTF-16转换为UTF-8 - Converting UTF-16 to UTF-8 using WideCharToMultiByte in C on Windows 如何将UTF-16转换为UTF-32并在C中打印生成的wchar_t? - How to Convert UTF-16 to UTF-32 and Print the Resulting wchar_t in C? 从UTF-8到UTF-16大字节序的字符串转换失败(使用C,C ++语言) - String conversion from UTF-8 to UTF-16 Big endian is failing (using C, C++ language) C:确定UTF-8字符串中UTF-16字符串需要多少字节的最有效方法 - C: Most efficient way to determine how many bytes will be needed for a UTF-16 string from a UTF-8 string
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM