views:

954

answers:

3

I need a good Unicode library for C++. I need:

  1. Transformations in a Unicode sensitive way. For example sort all strings in a case insensitive way and get their first characters for index. Convert various Unicode strings to upper and to lower case. Split text at a reasonable position -- words that would work for Chinese and Japanese as well.
  2. Formatting numbers, dates in locale sensitive way (should be thread safe).
  3. Transparent support of UTF-8 (primary internal representation).

As far as I know the best library is ICU. However, I can't find normal developer friendly API documentation with examples. Also as far as I see, it is not too friendly with modern C++ design, work with STL and so on. Like this:

std::string msg;
unistring umsg.from_utf8(msg);
unistring::word_iterator wi;
for(wi=umsg.words().begin(),n=0;wi!=usmg.words().wi_end(),n<10;++wi,++n) 
  ;
msg=umsg.substr(umsg.words().begin(),wi).to_utf8();
cout<<_("Five 10 words are ")<<msg;

Is there a good STL friendly ICU wrapper released under Open Source license? Preferred is a license permissive like MIT or Boost, but others, like LGPLv2 compatible, are OK as well.

Is there another high quality library similar to ICU?

Platform: Unix/POSIX, Windows support is not required.

Edit: unfortunately I wasn't logged in, so I can't make accept an answer. I have attached the answer by myself.

+1  A: 

The wxWidgets GUI toolkit has some rather nice string classes and unicode support. You don't need to build/use GUI classes if you don't want to. See here for details.

Eduard - Gabriel Munteanu
+1  A: 

Does this fit the bill?

http://www.codeproject.com/KB/string/utf8cpp.aspx

Rob
It seems that provides only a small subset of what is required. It simply allows handling UTF-8 String, but doesn't support toLower/toUpper/formatting numbers/...
Joachim Sauer
True - it is only for handling utf-8 strings, but it can easily be coupled with Boost String Algorithms. Of course, even then it does not replace ICU.
Nemanja Trifunovic
+6  A: 

This question was asked quite a long time before by myself. There was no such library.

So I had written C++ friendly Boost.Locale library that wraps ICU.

Artyom
This is awesome. Did you make a Boost submission?
Pavel Minaev
I've started an inital preliminary process - before the official submission. Follow the boost mailing lists
Artyom