便携和简单的单向code串库C / C ++? [英] Portable and simple unicode string library for C/C++?

查看:78
本文介绍了便携和简单的单向code串库C / C ++?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在寻找一种便携式,易于使用的字符串库C / C ++,这有助于我与统一code输入/输出工作。在最好的情况下,将其存储在内存中的字符串UTF-8,并让我从字符串转换成ASCII码为UTF-8 / UTF-16和背部。除此之外(好吧,一个自由的许可证不会伤害),我不需要更多。我已经看到,C ++自带的<一个href=\"http://dinkumware.com/manuals/default.aspx?manual=compleat&page=locale2.html\"><$c$c><locale>头,但这似乎对工作 wchar_t的只是,这可能是也可能不是UTF-16连接codeD,再加上我不知道这其实是多么好

I'm looking for a portable and easy-to-use string library for C/C++, which helps me to work with Unicode input/output. In the best case, it will store its strings in memory in UTF-8, and allow me to convert strings from ASCII to UTF-8/UTF-16 and back. I don't need much more besides that (ok, a liberal license won't hurt). I have seen that C++ comes with a <locale> header, but this seems to work on wchar_t only, which may or may not be UTF-16 encoded, plus I'm not sure how good this is actually.

用例是,例如:在Windows上,UNI code API的期望UTF-16字符串,我需要转换ASCII或UTF-8字符串传递它的API。同去的XML解析,这可能会与UTF-16,但其实我只想要使用UTF-8内部处理(或者,对于这个问题,如果我在内部转换为UTF-16,我需要转换到反正)。

Uses cases are for example: On Windows, the unicode APIs expect UTF-16 strings, and I need to convert ASCII or UTF-8 strings to pass it on to the API. Same goes for XML parsing, which may come with UTF-16, but I actually only want to process internally with UTF-8 (or, for that matter, if I switch internally to UTF-16, I'll need a conversion to that anyway).

到目前为止,我已经采取了看 ICU ,这是相当巨大的。此外,要使用它自己的项目文件中创建的,而我preFER对此有或者是CMake的项目或者是很容易建立(东西像库编译所有这些.c文件,链接和好走),而不要运大东西沿着我的申请加护病房。

So far, I've taken a look at the ICU, which is quite huge. Moreover, it wants to be built using it own project files, while I'd prefer a library for which there is either a CMake project or which is easy to build (something like compile all these .c files, link and good to go), instead of shipping something large as the ICU along my application.

你知不知道这样的库,这也被保持?毕竟,这似乎是一个pretty基本问题。

Do you know such a library, which is also being maintained? After all, this seems to be a pretty basic problem.

推荐答案

UTF8-CPP 似乎是正是你想要的。

UTF8-CPP seems to be exactly what you want.

这篇关于便携和简单的单向code串库C / C ++?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆