Closed
Bug 856115
Opened 11 years ago
Closed 5 years ago
String.localeCompare() doesn't work consistently in Linux
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
FIXED
People
(Reporter: jennifer.chye, Unassigned)
References
(Depends on 1 open bug)
Details
Attachments
(1 file)
134 bytes,
text/plain
|
Details |
Open the attached file in Firefox which prints out the result of running "'côte'.localeCompare('coté')" in JavaScript. A negative number will be displayed on the page. On the same page, open the web console and enter "'côte'.localeCompare('coté')". A positive number will be returned. Both the page and the web console should have displayed a positive number according to the spec for localeCompare(). This bug was found in Ubuntu 12.04 LTS. It does not occur in Firefox for OS X.
Updated•11 years ago
|
Assignee: nobody → general
Component: General → JavaScript Engine
Product: Firefox → Core
Comment 1•11 years ago
|
||
We're in the process of switching this stuff over to being done with ICU in a future release (22 quite possibly), so hopefully this will go away then.
Comment 2•11 years ago
|
||
It's not guaranteed that this problem will go away. In the old implementation, the browser installed a comparison function into JavaScript runtimes that was based on string comparison in the operating systems. If the web console behaves differently from browser windows, it probably means that it doesn't get such a comparison function, and therefore uses the primitive string comparison in ECMAScript, which just compares UTF-16 code units. In the new implementation, it's all based on ICU, but the behavior varies between locales. Those JS runtimes that in the old implementation received a comparison function now receive the browser's default locale. JS runtimes that don't receive the browser's default locale use the operating system's. So, if the browser and the operating system don't agree on the default locale, there may be differences in behavior. To make sure that you get correct comparisons between 'côte' and 'coté', you can specify French as the locale for localeCompare: "'côte'.localeCompare('coté', 'fr')". This makes the comparison independent of default locales in the new implementation. The old implementation doesn't know the locales argument and simply ignores it.
Assignee | ||
Updated•10 years ago
|
Assignee: general → nobody
Comment 3•5 years ago
|
||
I think this is already fixed as we do use ICU now everywhere. Reopen if needed.
Status: UNCONFIRMED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•