Hi Dave (W),
Thanks for your notes and observations.
Just for clarity ^_^
* About the only common platform we don't compile under is Microsoft - our code
base is for unix-flavours. :D.
* AFAIK UTF-* formats are not fixed length encodings and, AFAIK, the wchar_t
is always fixed length.
- (Are you sure that Microsoft wchar_t IS UTF-16 (LE) and not UCS-2 (LE)?
I do not know - just curious).
* Under a default gcc compile on Linux, L defines a four byte character, not a
two byte one. It isn't UTF-32.
* XMLCh is not always defined as wchar_t - as you discovered. Eg. on Mac OS X
it's uint16_t by default. I need to allow for that.
* Yes, const wchar_t szSysName[] = L"System font"; is legal - AFAIK,
difficulties arise when you need a static cast over the declaration.
Regarding your suggestion of a class derivation for the STL template instance
std::basic_string<XMLCh> , at some point it may well be worthwhile for us to
define an internal string class for dealing with all these issues, but
currently, I am quite happy to continue to use std::basic_string<XMLCh> or a
typdef. My main issue is with the way of declaring literals.
The preprocessor directive I am using at the moment is
#define UCS2(x) (const XMLCh*)(x)
So that I can declare literals as follows:
const XMLCh* myAnyString= UCS2(L"ANY"); //not perfect but better than const
XMLCh myAnyString[] = { chLatin_A, chLatin_N, chLatin_Y, chNull }; // "ANY"
I am happy enough with a static cast over L - especially as it seems the two
XMLCh options will work - it will either be redundant or it will be a reliable
cast.
-B