views:

781

answers:

4

I was looking recently for a toolkit/library with good unicode support. I had checked ICU, Qt3, Qt4 and Glib. Unfortunalty all of them with exception of ICU had some missing features or had implemented them incorrectly.

Unfortunalty, ICU library has quite bad documentation and is very hard to use because it ignores most of modern C++ designs.

So, I'm looking for a good ICU tutorial with examples and explanations of rationale behind these functions. Descriptions how to do things correctly to be able to write a friendly wrapper for it.

+1  A: 

The ICU Project has a number of examples for various aspects of the ICU. I've used this resource several times when dealing with the ICU API.

Aaron Saarela
I had definitely seen this site and the tutorial, but I still see them as very low quality documentation.
Artyom
What portions of the documentation are you having trouble with?
Aaron Saarela
A: 

I created a small helper template to convert to and from UTF-8 to wstring using the ICU functions u_strFromWCS and u_strFromUTF8 and had no problems using ICU whatsoever. All my processing is done internally in wstring (like boost::regexp) and I only need the conversion functions to do the IO of the wstrings (like printing them to cout).

Maybe you need to describe more about what problems you want to solve, so that someone can point you to the right place in the documentation.

lothar
Actually for these purposes you don't need ICU, even C++ provides such functionality via std::locale interface.
Artyom
as boost can be configured to use ICU for unicode support there was no reason not to use it :-)
lothar
A: 

Me too having trouble with the sub optimal ICU tutorial. I

am trying to read in utf8 text from a file using getline() and storing in a std::sting.

I would like to now lowercase the text and then write it back to another file also in UTF8.

It appears I can use U8_NEXT() to read the UTF-8 text from the const char* returned by string::c_str() . So far this is what i have. Now I am unable to figure out how to do the transformation and write it to another file in UTF-8 format. Any help would be appreciated.

codie
See this: http://icu-project.org/apiref/icu4c/classUnicodeString.html#e24fb796b206b8dbedc800a6d3c57f3e
Artyom
I have seen this page, but its not obvious from that... how to convert things finally to UTF8. I see the UnicodeString::toUTF8() method but it takes a ByteSink argument. The real issue is I dont see the ByteSink concept explained (other than reference docs for its members)
codie
A: 

Unfortunately there is nothing better. It just takes time to get used to ICU concepts.

It is very important to actually refer to reference documentation and search in it. As it makes the situation more complete.

Artyom