On Mon, Feb 19, 2007 at 06:49:20PM +0100, Julien Claassen wrote:
> Hello!
>   I've got one question. I'm writing a library in c++, which needs to handle 
> different character sets. I suppose for internal purposes UTF-8 is quite 
> sufficient. So is there a standard string class in the libstdc++ which 
> supports it?
>   Can I use something like:
>   printw(0,0,"%s",my_utf8_string.c_str());
>   with it?

The whole point of UTF-8 is that it's usable directly as a normal
string. You don't need any special classes, just a normal string
class. If you want to add extra UTF-8-specific functionality you could
perhaps make a derived class.

>   Is there some kind of good, small example code of how to use libiconv most 
> efficiently with strings in c++?

Not sure what you mean by most efficiently. If you're converting from
another encoding to UTF-8, I would just initially allocate some small
constant times the original size in the legacy encoding (3 times
should be sufficient; 4 times surely is), then use iconv to convert
into the allocated buffer, and subsequently resize it to free the
unused space if you care about space.

Sorry my suggestions aren't very C++-specific. I only use C and am not
very fond of C++ so I'm not particularly familiar with it.

>   Any good hints are appreciated! Thanks!

Hope this helps a little bit. If you have more specific questions feel
free to ask (on-list please).

Rich

--
Linux-UTF8:   i18n of Linux on all levels
Archive:      http://mail.nl.linux.org/linux-utf8/

Reply via email to