Re: portable Unicode programming.
On Jan 27, 6:24 am, "JCR" <j...@yahoo.com> wrote:
Thanks for the link. In the meantime, would you advise to use
std::wstring, a typedef std::wstring MyString (and, later, change it to
std:ustring or whatever name it will have in C++0x), or maybe choose
one of those Unicode libraries (and adding another dependency...)? The
project is a C++ CGI framework to build websites (that's why Unicode
matters so much) and right now it is std::string, moving relunctantly
to std::wstring.
In our web framework (FOST.3) we have written our own string class that
looks much like std::wstring, but the character parts of the interface
are changed to be UTF-32 (i.e. character counts, substr positions and
operator[] and at() - iterators also iterate through UTF-32 characters)
but internally it uses UTF-16. The non-const operator [] got dropped
because it's pretty awkward to write and using it for string processing
could be no more efficient than using substr anyway.
If all you are doing is web though then you may find it better to stick
with UTF-8 as there will be less processing involved. We use a database
backend through COM so UTF-16 is more natural for us - we do a final
UTF-8 conversion on output.
Using UTF-8 throughout will also make it easier to port to other
platforms because they can all handle std::string, but some use 32 bit
wchar_t rather than 16 bit so you'll need different implementations of
the wstring class for them.
K
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]