Search code examples
javaandroidcollator

Collator - different collation rules in Android and Windows for the same US locale


If I run the code in Eclipse / Windows, I get different results than if I run the code in Android.

After importing the jar library into Android project, the Collator is giving me different results for dash and forward slash characters.

I was expecting similar behavior.

Can somebody explain this?

package java.text;

    Collator myCollator = Collator.getInstance(Locale.US);

Result:

myCollator.compare(" ", "-") 

In Windows: -1 In Android: 1

myCollator.compare("/", ".") 

In Windows: -1 In Android: 1

The Windows results seem to be correctly sorted according to this table here:

https://documentation.progress.com/output/ua/Corticon/index.html#page/corticon/character-precedence-3a-unicode-and-java-collator.html

But the results in Android are not.


Solution

  • Apparently, there are differences in the collator for the Android environment and Windows Java SDK.