-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"".localeCompare("\u0000") return -1, should it be 0? #32819
Labels
i18n-api
Issues and PRs related to the i18n implementation.
Comments
@nodejs/i18n-api |
The collation weight may matter here, U+0000 NUL is default ignorable, but the left hand side is an empty (0 length) string. |
v8 has the same behavior as node. |
|
If this is still an issue it sounds like should be filed against v8 |
$ node
Welcome to Node.js v22.5.1.
Type ".help" for more information.
> "".localeCompare("\u0000")
0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What steps will reproduce the bug?
Evaluate
"".localeCompare("\u0000");
What is the expected behavior?
Firefox reports 0.
ECMA-402 says "The method is required to return +0 when comparing Strings that are considered canonically equivalent by the Unicode standard." https://ecma-international.org/ecma-402/6.0/index.html#sec-collator-comparestrings
What do you see instead?
node reports -1
Additional information
I'm not enough of a Unicode expert to say if "" and "\u0000" are "canonically equivalent" but the inconsistency between firefox and nodejs suggests that one of the two projects has a bug. I reported to firefox here: https://bugzilla.mozilla.org/show_bug.cgi?id=1629547
The text was updated successfully, but these errors were encountered: