"KRAUSE,MIKE (HP-FtCollins,ex1)" wrote:
>
> Hi,
>
> Just a comment to add to this discussion... I don't think the DOM spec
> requires case insensitive compares of strings, but it would be nice if there
> were a way of doing case insensitive compares without having to do a
> translation to a char * (using transcode) and then doing a strcmpi on the
> strings.
The specs *require* case sensitive comparisons, because of various
internationalization problems,
including sensitivity to locale.
Adding a simple caseSensitiveCompare() doesn't solve the problem (see below --
what if you're in
Quebec?). So, if you really want this function, use the ICU or iconv, and call
its Unicode
functions:
UnicodeString& toUpper(void)
Convert the characters in this to UPPER CASE following the
conventions
of the default locale
UnicodeString& toUpper(const Locale& locale)
Convert the characters in this to UPPER CASE following the
conventions of a
specific locale
and the corresponding toLower functions.
NOTE: As I recall, there are also locale-sensitive issues where:
compare(toUpper(string1), toUpper(string2))
is not always equal to
compare(toLower(string1), toLower(string2))
so, the definition of "case insensitive" ends up being both unclear, and locale
sensitive.
Here's an example from the annotated spec:
"What is the
upper-case version of the
character "�"? It turns out
the answer is sometimes
different depending on
whether you're in Qu�bec or
France. Then there are the
problems with the German
"�" and the dotless Turkish
"i", and in general... well,
you want to stay away from
case-folding. So XML
does."
Bottom line: stay away from case insensitive comparisons.
Mike