localeCompare is wrong in Android vs iOS
See original GitHub issueDescription
It seems that localeCompare
works differently in iOS and Android. In Android it doesn’t return the expected value.
Reproduction
'a'.localeCompare('A', 'es', { sensitivity: 'base', caseFirst: false })
In Google Chrome in Mac returns 0 in Android 6.0.1 react-native (device and emulator) returns 1 in iOS 10.2 react-native returns 0
It’s my understanding that localeCompare
is not reliable in Android for anything that is not English. I don’t know if this is an error in v8 engine, but I believe this was patched in v8-i18n, so not sure if this can be fixed in RN or not
Additional Information
- React Native version: 0.39.2
- Platform: Android 6.0.1
Issue Analytics
- State:
- Created 7 years ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
String.prototype.localeCompare() - JavaScript - MDN Web Docs
The localeCompare() method returns a number indicating whether a reference string comes before, or after, or is the same as the given string ......
Read more >Date formatting error in Android in React native
Your React Native JS code is executing within a javascript engine, which differs between iOS and Android. iOS - uses the JavaScriptCore ...
Read more >String.prototype.localeCompare()
The localeCompare() method returns a number indicating whether a reference string comes before or after or is the same as the given string ......
Read more >LocaleCompare returns incorrect result for "--" and "- -" ...
Issue 396485: LocaleCompare returns incorrect result for "--" and "- -" in Chrome as compared to IE and Mozilla. Reported by schedule ajay....
Read more >what went wrong: a problem occurred configuring project ...
I added the file in android/app/ folder and now it's working. ... this means * // that we don't look at files in...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The issue is closed, but is this ever going to be addressed in RN or are we supposed to build our own version of JSC and distribute it with our Apps???
react-native does not use v8 on Android by the way, so that’s irrelevant.