feat(libSceIcu): resolve i-default through the default locale #21964

Merged
sarveshgamers merged 2 commits from upstream-pr/21964 into main 2026-11-28 04:00:13 +00:00
sarveshgamers commented 2026-11-16 23:30:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by sarveshgamers on 2026-11-16T23:30:03Z.


What

uloc_getBaseName and uloc_canonicalize replace the i-default locale ID, with any subtags after it, by the default locale, as ICU 78.1's _canonicalize does (uloc.cpp). Both parse the default first: the base name takes the input's POSIX charset when present, and the canonical ID takes the input's keywords when present and otherwise keeps the default's, so a default set with uloc_setDefault cannot leak its keywords into the base name, duplicate them in the canonical ID, or add a second charset suffix. SetSystemDefault canonicalizes a system ID that is itself an i-default ID through the same non-recursive canonicalization, so resolving the sentinel cannot recurse and LANG=i-default and LANG=i-default-... keep main's canonical names.

The new behavior is exercised by guest_icu_locale_core and by four guest_icu_default_locale scenarios, including LANG=i-default and LANG=i-default-extra to cover the recursion guard, and defaults with keywords and a charset.

Tested

Windows 11, WinLibs MinGW-w64 GCC 16.2.0 (SEH). The changed sources pass g++ -fsyntax-only; a focused host harness reproduced the three review cases and the LANG=i-default, LANG=i-default-extra and LANG=i-default_US system defaults with the expected names. The full ctest suite was not run in this workspace because the third-party submodules are not checked out; the PR's CI jobs run it.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of the i-default locale ID. Locale name lookups now resolve it using the configured default locale while preserving relevant subtags, charset suffixes, and keywords.
    • Locale IDs that do not match the supported i-default form continue to be handled as regular locale IDs.
  • Documentation

    • Updated locale behavior documentation, including the expected comparison with the console.
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5347151112 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21964). Originally posted by [sarveshgamers](https://github.com/sarveshgamers) on 2026-11-16T23:30:03Z. --- ### What `uloc_getBaseName` and `uloc_canonicalize` replace the `i-default` locale ID, with any subtags after it, by the default locale, as ICU 78.1's `_canonicalize` does ([uloc.cpp](https://github.com/unicode-org/icu/blob/049e0d6a420629ac7db77256987d083a563287b5/icu4c/source/common/uloc.cpp#L1865-L1868)). Both parse the default first: the base name takes the input's POSIX charset when present, and the canonical ID takes the input's keywords when present and otherwise keeps the default's, so a default set with `uloc_setDefault` cannot leak its keywords into the base name, duplicate them in the canonical ID, or add a second charset suffix. `SetSystemDefault` canonicalizes a system ID that is itself an `i-default` ID through the same non-recursive canonicalization, so resolving the sentinel cannot recurse and `LANG=i-default` and `LANG=i-default-...` keep `main`'s canonical names. The new behavior is exercised by `guest_icu_locale_core` and by four `guest_icu_default_locale` scenarios, including `LANG=i-default` and `LANG=i-default-extra` to cover the recursion guard, and defaults with keywords and a charset. ### Tested Windows 11, WinLibs MinGW-w64 GCC 16.2.0 (SEH). The changed sources pass `g++ -fsyntax-only`; a focused host harness reproduced the three review cases and the `LANG=i-default`, `LANG=i-default-extra` and `LANG=i-default_US` system defaults with the expected names. The full `ctest` suite was not run in this workspace because the third-party submodules are not checked out; the PR's CI jobs run it. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) and the licence notice of code adapted from upstream (see AGENTS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * Improved handling of the `i-default` locale ID. Locale name lookups now resolve it using the configured default locale while preserving relevant subtags, charset suffixes, and keywords. * Locale IDs that do not match the supported `i-default` form continue to be handled as regular locale IDs. * **Documentation** * Updated locale behavior documentation, including the expected comparison with the console. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
PrivacyOnion commented 2026-11-16 23:31:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-16T23:31:19Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 498fca489c:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_icu_default_locale_tests, guest_icu_locale_core_tests built cleanly.
  • CTest (guest_icu_default_locale_posix, guest_icu_default_locale_messages, guest_icu_default_locale_codeset, guest_icu_default_locale_nynorsk, guest_icu_default_locale_long, guest_icu_default_locale_i-default, guest_icu_default_locale_i-default-system, guest_icu_locale_core):
    1/8 Test #3673: guest_icu_default_locale_posix ..............   Passed    0.00 sec
    2/8 Test #3682: guest_icu_locale_core .......................   Passed    0.01 sec
    3/8 Test #3674: guest_icu_default_locale_messages ...........   Passed    0.01 sec
    4/8 Test #3675: guest_icu_default_locale_codeset ............   Passed    0.01 sec
    5/8 Test #3676: guest_icu_default_locale_nynorsk ............   Passed    0.01 sec
    6/8 Test #3677: guest_icu_default_locale_long ...............   Passed    0.01 sec
    7/8 Test #3678: guest_icu_default_locale_i-default ..........   Passed    0.01 sec
    8/8 Test #3679: guest_icu_default_locale_i-default-system ...   Passed    0.00 sec
    100% tests passed, 0 tests failed out of 8
    
  • Negative control: with core/libs/prx/libSceIcu/DefaultLocale.cpp, core/libs/prx/libSceIcu/DefaultLocaleName.hpp, core/libs/prx/libSceIcu/LocaleCore.cpp reverted to main and the new tests kept, the suite fails:
    2/8 Test #3676: guest_icu_default_locale_nynorsk ............   Passed    0.01 sec
    3/8 Test #3674: guest_icu_default_locale_messages ...........   Passed    0.01 sec
    4/8 Test #3677: guest_icu_default_locale_long ...............   Passed    0.01 sec
    5/8 Test #3675: guest_icu_default_locale_codeset ............   Passed    0.01 sec
    6/8 Test #3682: guest_icu_locale_core .......................Subprocess aborted***Exception:   0.16 sec
    7/8 Test #3673: guest_icu_default_locale_posix ..............   Passed    0.00 sec
    8/8 Test #3679: guest_icu_default_locale_i-default-system ...Subprocess aborted***Exception:   0.12 sec
    63% tests passed, 3 tests failed out of 8
    
    Restoring the change makes it pass again.
  • Code reading:
    • Verified Icu::DefaultLocaleId logic in DefaultLocale.cpp for null safety and delimiter bounds checks ('\0', '_', '-', '.', '@')
    • Verified DefaultBaseName in LocaleCore.cpp correctly preserves POSIX charset encoding suffix and trims keyword specifiers from base name
    • Verified CanonicalName handling for i-default in uloc_canonicalize and uloc_getBaseName against ICU upstream behavior (uloc.cpp)
    • Verified SetSystemDefault recursion prevention when SystemLocaleId is an i-default variant
    • Verified AGENTS.md compliance, debt fragment tracking in docs/dev/debt/changes/feat-libSceIcu-locale-iso-codes.md, and test scenarios in DefaultLocale.cpp and GuestIcuLocaleCore.cpp

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5929801556 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21964#pullrequestreview-5929801556). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-16T23:31:19Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `498fca489c`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_icu_default_locale_tests`, `guest_icu_locale_core_tests` built cleanly. - **CTest** (`guest_icu_default_locale_posix`, `guest_icu_default_locale_messages`, `guest_icu_default_locale_codeset`, `guest_icu_default_locale_nynorsk`, `guest_icu_default_locale_long`, `guest_icu_default_locale_i-default`, `guest_icu_default_locale_i-default-system`, `guest_icu_locale_core`): ``` 1/8 Test #3673: guest_icu_default_locale_posix .............. Passed 0.00 sec 2/8 Test #3682: guest_icu_locale_core ....................... Passed 0.01 sec 3/8 Test #3674: guest_icu_default_locale_messages ........... Passed 0.01 sec 4/8 Test #3675: guest_icu_default_locale_codeset ............ Passed 0.01 sec 5/8 Test #3676: guest_icu_default_locale_nynorsk ............ Passed 0.01 sec 6/8 Test #3677: guest_icu_default_locale_long ............... Passed 0.01 sec 7/8 Test #3678: guest_icu_default_locale_i-default .......... Passed 0.01 sec 8/8 Test #3679: guest_icu_default_locale_i-default-system ... Passed 0.00 sec 100% tests passed, 0 tests failed out of 8 ``` - **Negative control**: with `core/libs/prx/libSceIcu/DefaultLocale.cpp`, `core/libs/prx/libSceIcu/DefaultLocaleName.hpp`, `core/libs/prx/libSceIcu/LocaleCore.cpp` reverted to `main` and the new tests kept, the suite fails: ``` 2/8 Test #3676: guest_icu_default_locale_nynorsk ............ Passed 0.01 sec 3/8 Test #3674: guest_icu_default_locale_messages ........... Passed 0.01 sec 4/8 Test #3677: guest_icu_default_locale_long ............... Passed 0.01 sec 5/8 Test #3675: guest_icu_default_locale_codeset ............ Passed 0.01 sec 6/8 Test #3682: guest_icu_locale_core .......................Subprocess aborted***Exception: 0.16 sec 7/8 Test #3673: guest_icu_default_locale_posix .............. Passed 0.00 sec 8/8 Test #3679: guest_icu_default_locale_i-default-system ...Subprocess aborted***Exception: 0.12 sec 63% tests passed, 3 tests failed out of 8 ``` Restoring the change makes it pass again. - **Code reading**: - Verified Icu::DefaultLocaleId logic in DefaultLocale.cpp for null safety and delimiter bounds checks ('\0', '_', '-', '.', '@') - Verified DefaultBaseName in LocaleCore.cpp correctly preserves POSIX charset encoding suffix and trims keyword specifiers from base name - Verified CanonicalName handling for i-default in uloc_canonicalize and uloc_getBaseName against ICU upstream behavior (uloc.cpp) - Verified SetSystemDefault recursion prevention when SystemLocaleId is an i-default variant - Verified AGENTS.md compliance, debt fragment tracking in docs/dev/debt/changes/feat-libSceIcu-locale-iso-codes.md, and test scenarios in DefaultLocale.cpp and GuestIcuLocaleCore.cpp Looks Good To Me
MarcZX10 commented 2026-11-20 07:44:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T07:44:50Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the review covers all changed files in the manifest, and the available evidence supports merging.

What I ran

Reviewed head d1c74cd42902a873ff9896bfabee56446bcfe34d using the prepared description, commit list, manifest, diff, and the pinned repository reader. No tests or builds were run; the Windows test run in the description is author-reported.

Results

Check Result Note
Changed code review passed All seven changed files were read
Automated tests not run Reported test results were not independently verified
Console comparison not run No console was available, per description

Findings

Blocking

None.

Non-blocking

None.

Sources

Reviewed core/libs/prx/libSceIcu/CMakeLists.txt, core/libs/prx/libSceIcu/DefaultLocale.cpp, core/libs/prx/libSceIcu/DefaultLocaleName.hpp, core/libs/prx/libSceIcu/LocaleCore.cpp, core/libs/prx/libSceIcu/tests/DefaultLocale.cpp, core/libs/tests/GuestIcuLocaleCore.cpp, and docs/dev/debt/changes/feat-libSceIcu-locale-iso-codes.md at the pinned head.

Not verified

Build and test results stated in the PR description, behavior on a physical console, and console comparison remain unverified. review/files.json was not available through the reader; changed-file coverage was checked against review/manifest.json and the review folder listing.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5989159989 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21964#pullrequestreview-5989159989). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T07:44:50Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the review covers all changed files in the manifest, and the available evidence supports merging. ## What I ran Reviewed head `d1c74cd42902a873ff9896bfabee56446bcfe34d` using the prepared description, commit list, manifest, diff, and the pinned repository reader. No tests or builds were run; the Windows test run in the description is author-reported. ## Results | Check | Result | Note | |---|---|---| | Changed code review | passed | All seven changed files were read | | Automated tests | not run | Reported test results were not independently verified | | Console comparison | not run | No console was available, per description | ## Findings ### Blocking None. ### Non-blocking None. ## Sources Reviewed `core/libs/prx/libSceIcu/CMakeLists.txt`, `core/libs/prx/libSceIcu/DefaultLocale.cpp`, `core/libs/prx/libSceIcu/DefaultLocaleName.hpp`, `core/libs/prx/libSceIcu/LocaleCore.cpp`, `core/libs/prx/libSceIcu/tests/DefaultLocale.cpp`, `core/libs/tests/GuestIcuLocaleCore.cpp`, and `docs/dev/debt/changes/feat-libSceIcu-locale-iso-codes.md` at the pinned head. ## Not verified Build and test results stated in the PR description, behavior on a physical console, and console comparison remain unverified. `review/files.json` was not available through the reader; changed-file coverage was checked against `review/manifest.json` and the review folder listing. ## To get this to a good state Nothing is required.
MarcZX10 commented 2026-11-26 21:27:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-26T21:27:32Z.

Review: COMMENTED


Reviewed — no blocking findings

The reviewed code shows no verified blocking defect; I could not run the reported tests or confirm behavior on console hardware.

What I ran

Reviewed head 15108f39a0873954c3a807aab96726d42cc95128. I inspected the prepared diff and manifest, plus relevant changed code and context; no commands or tests were run.

Results

Check Result Note
Code review passed Relevant changed code inspected
Automated tests not run Description reports 8/8 passing; not independently verified
Console comparison not run No console was available, per description

Findings

Blocking

None.

Non-blocking

None.

Sources

Reviewed code at the pinned head, including the changed locale handling and tests.

Not verified

Tests and console behavior were not verified. Read the prepared description, commits, manifest, and diff, and the changed files core/libs/prx/libSceIcu/CMakeLists.txt, core/libs/prx/libSceIcu/DefaultLocale.cpp, core/libs/prx/libSceIcu/DefaultLocaleName.hpp, core/libs/prx/libSceIcu/LocaleCore.cpp, core/libs/prx/libSceIcu/tests/DefaultLocale.cpp, core/libs/tests/GuestIcuLocaleCore.cpp, and docs/dev/debt/changes/feat-libSceIcu-locale-iso-codes.md. For LocaleCore.cpp and the CMake file, I read the changed hunks and targeted context rather than the entire files. The manifest lists all seven changed files as included; none were excluded by its rules.

To get this to a good state

Nothing is required. Optionally, run the reported test command on this head and complete the planned console comparison.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6080632255 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21964#pullrequestreview-6080632255). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-26T21:27:32Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The reviewed code shows no verified blocking defect; I could not run the reported tests or confirm behavior on console hardware. ## What I ran Reviewed head `15108f39a0873954c3a807aab96726d42cc95128`. I inspected the prepared diff and manifest, plus relevant changed code and context; no commands or tests were run. ## Results | Check | Result | Note | |---|---|---| | Code review | passed | Relevant changed code inspected | | Automated tests | not run | Description reports 8/8 passing; not independently verified | | Console comparison | not run | No console was available, per description | ## Findings ### Blocking None. ### Non-blocking None. ## Sources Reviewed code at [the pinned head](https://github.com/boykopovar/AnyPS5/tree/15108f39a0873954c3a807aab96726d42cc95128), including the changed locale handling and tests. ## Not verified Tests and console behavior were not verified. Read the prepared description, commits, manifest, and diff, and the changed files `core/libs/prx/libSceIcu/CMakeLists.txt`, `core/libs/prx/libSceIcu/DefaultLocale.cpp`, `core/libs/prx/libSceIcu/DefaultLocaleName.hpp`, `core/libs/prx/libSceIcu/LocaleCore.cpp`, `core/libs/prx/libSceIcu/tests/DefaultLocale.cpp`, `core/libs/tests/GuestIcuLocaleCore.cpp`, and `docs/dev/debt/changes/feat-libSceIcu-locale-iso-codes.md`. For `LocaleCore.cpp` and the CMake file, I read the changed hunks and targeted context rather than the entire files. The manifest lists all seven changed files as included; none were excluded by its rules. ## To get this to a good state Nothing is required. Optionally, run the reported test command on this head and complete the planned console comparison.
MarcZX10 commented 2026-11-27 17:51:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-27T17:51:42Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the review supports merging, and the points below are optional.

What I ran

Reviewed head a45ef80cf705b102b23f0ec86e2386340910c76d from the prepared diff and source at the pinned head. I did not run commands or tests.

Results

Check Result Note
Diff and targeted source review passed Changed behavior and relevant callers inspected
Automated tests not run No test execution in this review

Findings

Blocking

None.

Non-blocking

None.

Not verified

Tests and console behavior were not run or independently confirmed. Read all seven changed files listed in the manifest, including each added line. The review folder’s files.json was not available through the reader; the manifest lists all changed files as included. No changed files were excluded in the manifest.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6091756629 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21964#pullrequestreview-6091756629). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-27T17:51:42Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the review supports merging, and the points below are optional. ## What I ran Reviewed head `a45ef80cf705b102b23f0ec86e2386340910c76d` from the prepared diff and source at the pinned head. I did not run commands or tests. ## Results | Check | Result | Note | |---|---|---| | Diff and targeted source review | passed | Changed behavior and relevant callers inspected | | Automated tests | not run | No test execution in this review | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified Tests and console behavior were not run or independently confirmed. Read all seven changed files listed in the manifest, including each added line. The review folder’s `files.json` was not available through the reader; the manifest lists all changed files as included. No changed files were excluded in the manifest. ## To get this to a good state Nothing is required.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!21964
No description provided.