To interpret case-insensitive string locale independently
Xuelei Fan
xuelei.fan at oracle.com
Sun Jul 10 20:40:15 PDT 2011
Hi,
A lot of protocols and application need to use case-insensitive strings.
It's common that, for case-insensitive string, we convert it to lower
case or upper case before doing comparing, hash-code operations.
However, we may run into the locale dependency trap when calling
String.toUpperCase() and String.toLowerCase().
It may looks weird that, "config".toUpperCase() may not equal to
"CONFIG".toUpperCase(), and hence "config".toUpperCase().hashCode() may
not equal to "CONFIG".toUpperCase().hashCode().
Details, please read my post, "The Trap of Case-Insensitive String",
http://sim.ivi.co/2011/07/trap-of-case-insensitive-string.html.
And I wrote a simple script to check the trap of case-insensitive string.
http://sim.ivi.co/2011/07/simple-shell-script-to-check-trap-of.html
It's not a big issue, as for most the locales, "config".toUpperCase()
does equal to "CONFIG".toUpperCase(). But to make the product
universally available, it may be worthy of mitigating the locale
dependency of case-insensitive string. I have run the script on JDK
workspace, and filled a few bugs that may have the potential rick of
locale dependency.
To make the products locale independent, I would like you check the
potential locale dependency risks in your products.
I'd really like to get feedback on the blog posts.
Regards,
Xuelei
More information about the jdk8-dev
mailing list