[linux-audio-dev] [completely OT] c++ and UTF-8 question

Bob Ham rah at bash.sh
Tue Feb 20 23:57:34 UTC 2007


On Mon, 2007-02-19 at 18:04 -0500, Paul Davis wrote:
> On Mon, 2007-02-19 at 19:49 -0300, Camilo Polyméris wrote:
> > Julien Claassen wrote:
> > > Hi!
> > >   I'm sorry to ask that here, but it seems I can't get an anser anywhere else.
> > >   Does the libstdc++ support UTF-8 strings? Or is there some simple example 
> > > code snippet somewhere to derive/modify something which would fullfill this 
> > > need?
> > >   Kindest regards and thanks!
> > >            Julien
> > >
> > > --------
> > >   
> > Not really, but it is easy to implement:
> >     typedef basic_string<wchar_t> string;
> > For UTF-16 (which is variable width) you'd have to supply your own 
> > char_traits, or reimplement some string functions.
> 
> Glib::ustring is probably what you want. Glib is not part of any
> graphics toolkit - it is a low level portability library providing lots
> of cross-platform and utility goodness.

It's worth noting that Glib::ustring stores strings as UTF-8 in memory,
as multi-byte strings (char *).  The C++ library supports wide-character
strings (wchar_t *) but doesn't support conversion from multi-byte to
wide-character.  The C library does (see code from previous post.)

Bob

-- 
Bob Ham <rah at bash.sh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://lists.linuxaudio.org/pipermail/linux-audio-dev/attachments/20070220/88ba7d2b/attachment.pgp>


More information about the Linux-audio-dev mailing list