Open Bug 1036383 Opened 10 years ago Updated 2 years ago

localeCompare() returns positive value when comparing letters with Chinese characters

Categories

(Core :: JavaScript: Internationalization API, defect)

x86
Windows XP
defect

Tracking

()

UNCONFIRMED

People

(Reporter: xefbfbd, Unassigned)

Details

(Keywords: dev-doc-needed)

Attachments

(1 file)

Attached file localeCompare tests
localeCompare() returns positive value when comparing letters([a-zA-Z]) with Chinese characters if locale is "zh-CN", "zh-TW" or undefined, after bug 853301 landed. Steps to reproduce: run in web console: "a".localeCompare("爱") "a".localeCompare("爱", "zh-CN") "a".localeCompare("愛", "zh-TW") Actual results: all return 1 Expected results: should all return negative values It affects all Firefox 29+ versions on windows now, might affect other platforms as well.
According to my understanding of http://unicode.org/cldr/trac/ticket/4020, the current behaviour is correct.
(In reply to André Bargull from comment #1) > According to my understanding of http://unicode.org/cldr/trac/ticket/4020, > the current behaviour is correct. Thank you very much for that information! After reading cldrbug 4020 and cldrbug 3522 (http://unicode.org/cldr/trac/ticket/3522), cldrbug 5577 (http://unicode.org/cldr/trac/ticket/5577) I think they should probably not reorder Hani (Hanzi, Kanji, Hanja) for zh locales. No reodrer for ja (japanese) according to cldrbug 3522 and pedberg wrote in cldrbug 5577 > ... this (Move Native scripts before Latin in sorting) should probably > be done for most non-Latin-script languages except CJK languages. I'll file a new ticket there to see if they are willing to revert the reorder for zh locales.
Depending on your needs, you may be able to use Unicode extension modifiers to select gb2312 resp. big5han collation ordering. For these two collation types, Latin characters are explicitly ordered before Hani. For example: "a".localeCompare("爱", "zh-CN-u-co-gb2312")
(In reply to uFFFD from comment #2) > > I'll file a new ticket there to see if they are willing to revert the > reorder for zh locales. Where is the new ticket? Can you give us the link?
In the current nightly: "a".localeCompare("爱") -1 "a".localeCompare("爱", "zh-CN") 1 "a".localeCompare("愛", "zh-TW") 1 "a".localeCompare("爱", "zh-CN-u-co-gb2312") -1 Can we close this bug?
(In reply to Zibi Braniecki [:gandalf][:zibi] from comment #5) > In the current nightly: > > "a".localeCompare("爱") > -1 > > "a".localeCompare("爱", "zh-CN") > 1 > > "a".localeCompare("愛", "zh-TW") > 1 > > "a".localeCompare("爱", "zh-CN-u-co-gb2312") > -1 > > Can we close this bug? as of 53.0a1 build id 20161206030203 on a simplified chinese version windows general.useragent.locale : en_US intl.locale.matchOS : false "a".localeCompare("爱") => 1 // opposite to your result! "a".localeCompare("爱", "zh-CN") => 1 "a".localeCompare("愛", "zh-TW") => 1 "a".localeCompare("爱", "zh-CN-u-co-gb2312") => -1 does the behavior of String.prototype.localeCompare(locales=undefined) depend on system language? that is too bad :(
If you don't pass an explicit locale, you get system-locale-based behavior. That's true of all the different locale-sensitive functions.
(In reply to xunxun from comment #4) > Where is the new ticket? Can you give us the link? sorry for the very late reply but i finally found out the the GB/T 13418-92 is excatly what i have been looking for http://www.moe.gov.cn/s78/A19/yxs_left/moe_810/s230/201001/t20100115_75608.html so here it is http://unicode.org/cldr/trac/ticket/9944 (In reply to Jeff Walden [:Waldo] (remove +bmo to email) from comment #7) > If you don't pass an explicit locale, you get system-locale-based behavior. > That's true of all the different locale-sensitive functions. thanks for your clarification! i guess localeCompare's MDN page needs this piece of information too :) https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: