question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

localeCompare is wrong in Android vs iOS

See original GitHub issue

Description

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:closed
  • Created 7 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
compojoomcommented, Dec 18, 2017

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???

1reaction
hey99xxcommented, Feb 27, 2017

react-native does not use v8 on Android by the way, so that’s irrelevant.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found