Unicode 和 Android NDK
有没有办法在 NDK 中使用 UTF-8/16 字符串而不包含 ICU 等多兆字节库? Android 内置了 ICU 吗?
Is there any way to use UTF-8/16 strings in the NDK without including a multi-megabyte library such as ICU? Is ICU built in to Android?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
std::string
能够直接存储 UTF-8。仅当您想以某种方式解析字符串时,您才需要特殊的库,例如 ICU。对于无需解析的简单输出,只需使用std::string
并忘记所有这些库。std::string
is capable of storing UTF-8 directly. You will need special libraries, like ICU, only if you want to parse strings in some way. For a simple output without parsing, just go withstd::string
and forget about all those libraries.如果您使用默认构建,包括所有这些,ICU只有几兆字节,数百个代码页和数百个语言环境的数据。
请查看“让 ICU 更小”。我刚刚添加了有关使用静态构建的注释。
华泰
ICU is only multimegabyte if you go with a default build including all this, hundreds of codepages and several hundred locales worth of data.
Have a look at "Making ICU Smaller". I just added a note about using static builds.
HTH
替代库:Iconv
大小:约 900kb(APK 中较小)
Alternative lib: Iconv
Size: about 900kb (which is smaller in APK)
如果您想要比 ICU 小的东西,请检查 UTF8-CPP 库。
If you want something smaller than ICU, check UTF8-CPP library.