Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

localeCompare implementation is not following the specification #11063

Closed
Eyesonly88 opened this issue Feb 11, 2013 · 9 comments
Closed

localeCompare implementation is not following the specification #11063

Eyesonly88 opened this issue Feb 11, 2013 · 9 comments
Assignees

Comments

@Eyesonly88
Copy link

Eyesonl...@gmail.com commented:

Which version of PhantomJS are you using? Tip: run 'phantomjs --version'.
I'm using version 1.8.1

What steps will reproduce the problem?

  1. run phantomjs and in the command line type
  2. 'a'.localeCompare('B')
  3. The result is 1

What is the expected output? What do you see instead?
The expected output is -1
Firefox and Chrome return -1. So they ignore the case sensitivity.
I see 1 in PhantomJs instead of -1

Which operating system are you using?
I'm using Windows 7 x64

Did you use binary PhantomJS or did you compile it from source?
I used binary (.exe)

Please provide any additional information below.
I think PhantomJS needs to ignore the case on the Strings used in the localeCompare() function just like Firefox18 and Chrome24

Disclaimer:
This issue was migrated on 2013-03-15 from the project's former issue tracker on Google Code, Issue #1063.
🌟   2 people had starred this issue at the time of migration.

@PVince81
Copy link

Any update on this ?

Also occurs on phantomjs 1.9.2 on Linux:

PhantomJS 1.9.2 (Linux) Core base tests naturalSortCompare sorts with different casing FAILED
        Expected [ 'AAA', 'BBB', 'aaa', 'bbb' ] to equal [ 'aaa', 'AAA', 'bbb', 'BBB' ].
..
PhantomJS 1.9.2 (Linux) Core base tests naturalSortCompare sorts with umlauts FAILED
        Expected [ 'ah.txt', 'oh.txt', 'uh.txt', 'Äh.txt', 'Öh.txt', 'Üh.txt', 'Üh 2.txt', 'äh.txt', 'öh.txt', 'üh.txt' ] to equal [ 'ah.txt', 'äh.txt', 'Äh.txt', 'oh.txt', 'öh.txt', 'Öh.txt', 'uh.txt', 'üh.txt', 'Üh.txt', 'Üh 2.txt' ].

This makes it impossible to use unit tests to verify sort orders with continuous integration.

@bryanrcampbell
Copy link

Hi there

Any update on this issue? Anyone know of a workaround?

Thanks!

@jhuesos
Copy link

jhuesos commented Mar 24, 2014

Also this:

'||'.localeCompare('or')

This returns -1 in Firefox and Chrome, but it returns 1 in PhantomJS 1.9.7.

I am assuming Firefox and Chrome both implements the method according to the standard

@kdzwinel
Copy link

👍

Our tests fail in PhantomJS because 'Å' > 'Z' according to localeCompare.

@Ephigenia
Copy link

👍

@vitallium
Copy link
Collaborator

Fixed in 2.0

@darynmitchell
Copy link

@vitallium will the localeCompare fix in 2.0 also address the following problem in 1.9 with combining diacritical marks, or should I make a new issue describing what I'm seeing here? —Thanks

var accent = "e with acute accent: é",  // Acute accented character
    combiningDiacritic = "e with acute accent: e\u0301"; // combining diacritical character
console.log('localeCompare: ' + combiningDiacritic.localeCompare(accent));

Chrome, Firefox output: 'localeCompare: 0'
PhantomJS output: 'localeCompare: -1'

tomka added a commit to catmaid/CATMAID that referenced this issue Feb 14, 2015
PhantomJS handles localeCompare unfortunately a bit differently, so we have to
do a different test for it.

See ariya/phantomjs#11063
@josesaldana
Copy link

Hi @vitallium. Appreciate your work (and all contributors') on this. I'm still seeing this issue even in 2.1.3. Wanted to confirm if something happened with the fix (if it got included or excluded by somehow). Thank you!

@lebolo
Copy link

lebolo commented Jun 1, 2016

I'm using v2.1.1 and 'A'.localeCompare('a', undefined, {numeric: true, sensitivity: 'base'}) is giving me -1 instead of 0.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants