_[email protected] commented:_
Which version of PhantomJS are you using? Tip: run 'phantomjs --version'.
I'm using version 1.8.1What steps will reproduce the problem?
- run phantomjs and in the command line type
- 'a'.localeCompare('B')
- 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 -1Which operating system are you using?
I'm using Windows 7 x64Did 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.
:star2: 2 people had starred this issue at the time of migration.
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.
Hi there
Any update on this issue? Anyone know of a workaround?
Thanks!
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
:+1:
Our tests fail in PhantomJS because '脜' > 'Z' according to localeCompare.
:+1:
Fixed in 2.0
@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? 鈥擳hanks
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'
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!
I'm using v2.1.1 and 'A'.localeCompare('a', undefined, {numeric: true, sensitivity: 'base'}) is giving me -1 instead of 0.
Most helpful comment
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!