In ECMAScript Third Edition (and hence both ActionScript and current browser JavaScript) there is the string.localeCompare
method. This does a comparison that depends on the current client locale. For example if I set my system locale (in Windows terms, “language to match the language version of the non-Unicode programs you want to use”) to “German (Germany)” and put javascript:alert('ä'.localeCompare('b'))
I get -1
, but with English I get 1
.
It's generally questionable to depend on the client end locale though. Your application would work differently depending on the client OS installation, and it is not nearly as easy for the user to change their system locale as it is to choose a different language in the web browser prefs UI. I'd avoid it if at all possible, and either:
do an ad-hoc string replacement (eg. ä
with ae
) before comparison. This may be OK if you are only worried about a few umlauts, but is unfeasible for covering the whole of Unicode... even the whole of the Latin diacritical set.
try to do the comparison on the server side, in a scripting language with better character model support than ECMAScript.