Re: portable Unicode programming.
Carlos Moreno wrote:
I wonder: shouldn't one be able to implement a unicode string class
using the same class std::string with a special char type and its
special char_traits?
In theory, or in practice? In practice, you can only
instantiate basic_string with char and wchar_t, using the
default arguments for the other template parameters. Some
implementations do allow more, but you can't count on it, and
what works with one implementation will fail with another.
If you accept that there is no IO, you might be able to get away
with a little more, but on the whole, I'd rate the
templatization of strings as an experiment which didn't turn out
quite the way it was hoped.
I'm thinking something similar to the case-insensitive string class
that Herb Sutter discusses in his "Exceptional C++" book --- from
what I recall from char_traits, there are operations to deal with
individual characters as well as sequences of characters, which
could give us what we need to be able to deal with UTF encodings.
Am I being too optimistic?
Very.
--
James Kanze (Gabi Software) email: james.kanze@gmail.com
Conseils en informatique orient?e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S?mard, 78210 St.-Cyr-l'?cole, France, +33 (0)1 30 23 00 34
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]