Skip to content

Normative: Add more explicit algorithms for lookups#92

Merged
FrankYFTang merged 8 commits intotc39:mainfrom
anba:lookup
Nov 18, 2025
Merged

Normative: Add more explicit algorithms for lookups#92
FrankYFTang merged 8 commits intotc39:mainfrom
anba:lookup

Conversation

@anba
Copy link
Copy Markdown
Contributor

@anba anba commented Aug 7, 2024

Add more explicit steps which should match the results when using ICU4C.

Being more explicit which Unicode extension keys are used is important for implementations like SpiderMonkey, which has to sanitize the locale identifier before passing it to ICU4C. SpiderMonkey allows locale identifier longer than ULOC_FULLNAME_CAPACITY (157 characters), so we have to sanitize the locale identifier before passing it to ICU4C, otherwise ICU4C will reject the locale identifier with U_BUFFER_OVERFLOW_ERROR. (I think this also applies to JSC.) V8 directly calls into ICU4C, so it inherits the ULOC_FULLNAME_CAPACITY restrictions and can't even create Intl.Locale with long locale identifiers.

When to use rg or sd or even fall back to the default locale seems a bit arbitrarily to me, but that's the current ICU4C behaviour, so it's what users will get in browsers. 🤷

a27bd64:

  • Use rg and sd Unicode extension keys to lookup the region.
  • Use "gregory" resp. "h23" if no calendar or time data is available.

df2d9cc:

81e9d12:

  • Use %Intl.NumberFormat% to lookup the default numbering system.
  • rg and sd Unicode extension keys are ignored.
  • Use "latn" if the locale isn't found in the available locales list of %Intl.NumberFormat%.

23d08eb:

  • Use %Intl.NumberFormat% to lookup the default numbering system.
  • rg and sd Unicode extension keys are ignored.
  • Use the default locale (!) if the locale isn't found in the available locales list of %Intl.Collator%.

Applies on top of #91.

Copy link
Copy Markdown
Collaborator

@FrankYFTang FrankYFTang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sffc sffc moved this from Priority Issues to Previously Discussed in ECMA-402 Meeting Topics Oct 9, 2025
@FrankYFTang
Copy link
Copy Markdown
Collaborator

We discuss this PR in TG2 2025-10-09 meeting and got all positive feedback and prefer to merge. Frank will bring to 2025 Nov TC39 TG1 meeting .

@sffc
Copy link
Copy Markdown
Contributor

sffc commented Oct 13, 2025

@FrankYFTang FrankYFTang merged commit a97b136 into tc39:main Nov 18, 2025
FrankYFTang added a commit to FrankYFTang/ecma402 that referenced this pull request Nov 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Previously Discussed

Development

Successfully merging this pull request may close these issues.

4 participants