Skip to content
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

Open
adamvy opened this issue Apr 13, 2020 · 5 comments
Open

"".localeCompare("\u0000") return -1, should it be 0? #32819

adamvy opened this issue Apr 13, 2020 · 5 comments
Assignees
Labels
i18n-api Issues and PRs related to the i18n implementation.

Comments

@adamvy
Copy link

adamvy commented Apr 13, 2020

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

@addaleax addaleax added the i18n-api Issues and PRs related to the i18n implementation. label Apr 13, 2020
@addaleax
Copy link
Member

@nodejs/i18n-api

@srl295 srl295 self-assigned this Apr 13, 2020
@srl295
Copy link
Member

srl295 commented Apr 13, 2020

The collation weight may matter here, U+0000 NUL is default ignorable, but the left hand side is an empty (0 length) string.

@srl295
Copy link
Member

srl295 commented Jul 10, 2020

v8 has the same behavior as node.

@devsnek
Copy link
Member

devsnek commented Jul 10, 2020

┌────────────────┬──────┐
│ ChakraCore     │ 0    │
│ GraalJS        │      │
│ JavaScriptCore │      │
│ SpiderMonkey   │      │
├────────────────┼──────┤
│ QuickJS        │ -1   │
│ V8             │      │
├────────────────┼──────┤
│ Moddable XS    │ -244 │
└────────────────┴──────┘

@srl295
Copy link
Member

srl295 commented Apr 4, 2023

If this is still an issue it sounds like should be filed against v8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
i18n-api Issues and PRs related to the i18n implementation.
Projects
None yet
Development

No branches or pull requests

4 participants