To interpret case-insensitive string locale independently
xuelei.fan at oracle.com
Sun Jul 10 20:40:15 PDT 2011
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",
And I wrote a simple script to check the trap of case-insensitive string.
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
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.
More information about the jdk8-dev