feat(libSceIcu): implement the default locale #20642

Merged
benjaminmathias merged 2 commits from upstream-pr/20642 into main 2026-11-16 01:46:11 +00:00
benjaminmathias commented 2026-11-15 11:37:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by benjaminmathias on 2026-11-15T11:37:36Z.


What

Implements the default locale of libSceIcu: uprv_getDefaultLocaleID, uloc_getDefault and uloc_setDefault, following the POSIX branch of ICU 68.2 putil.cpp and locale_set_default_internal in locid.cpp. The system ID comes from the guest setlocale(LC_MESSAGES, NULL), then LC_ALL, LC_MESSAGES and LANG in the guest environment, and is corrected as ICU does: the codeset is dropped, C/POSIX become en_US_POSIX, @variant is appended (nynorsk gives NY). It is read once. uloc_getDefault canonicalizes it with this module's uloc_canonicalize. A language field of 12 characters or more gives the empty name of a bogus Locale. Each default name stays valid after the default changes. uloc_setDefault(NULL) resets to the system default. A non-null ID throws NotImplemented_nid_no_patch, because ICU resolves it through uloc_getName, which this module does not implement yet. The default the console returns is not measured; the debt entry records this.

Tested

Windows 11 Pro, WinLibs GCC 15.2.0, full build with BUILD_TESTING=ON:

  • new guest_icu_default_locale_{posix,messages,codeset,nynorsk,long}: 5/5 passed (empty guest environment, LC_MESSAGES over LANG with a codeset and a variant, LC_ALL=C.UTF-8, no@nynorsk, an over-long language);
  • ctest -R "^guest_icu_": 52/52 passed.

Not tested on Linux or macOS. DefaultLocale.cpp and the libc sources it calls (StdioExtras.cpp, Environment.cpp) are built outside any WIN32 block.

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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5322289441 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20642). Originally posted by [benjaminmathias](https://github.com/benjaminmathias) on 2026-11-15T11:37:36Z. --- ### What Implements the default locale of libSceIcu: `uprv_getDefaultLocaleID`, `uloc_getDefault` and `uloc_setDefault`, following the POSIX branch of ICU 68.2 `putil.cpp` and `locale_set_default_internal` in `locid.cpp`. The system ID comes from the guest `setlocale(LC_MESSAGES, NULL)`, then `LC_ALL`, `LC_MESSAGES` and `LANG` in the guest environment, and is corrected as ICU does: the codeset is dropped, `C`/`POSIX` become `en_US_POSIX`, `@variant` is appended (`nynorsk` gives `NY`). It is read once. `uloc_getDefault` canonicalizes it with this module's `uloc_canonicalize`. A language field of 12 characters or more gives the empty name of a bogus `Locale`. Each default name stays valid after the default changes. `uloc_setDefault(NULL)` resets to the system default. A non-null ID throws `NotImplemented_nid_no_patch`, because ICU resolves it through `uloc_getName`, which this module does not implement yet. The default the console returns is not measured; the debt entry records this. ### Tested Windows 11 Pro, WinLibs GCC 15.2.0, full build with `BUILD_TESTING=ON`: - new `guest_icu_default_locale_{posix,messages,codeset,nynorsk,long}`: 5/5 passed (empty guest environment, `LC_MESSAGES` over `LANG` with a codeset and a variant, `LC_ALL=C.UTF-8`, `no@nynorsk`, an over-long language); - `ctest -R "^guest_icu_"`: 52/52 passed. Not tested on Linux or macOS. `DefaultLocale.cpp` and the libc sources it calls (`StdioExtras.cpp`, `Environment.cpp`) are built outside any `WIN32` block. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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
MarcZX10 commented 2026-11-15 13:39:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-15T13:39:33Z.

Review: APPROVED


Reviewed — looks good

The locale implementation and its focused tests are consistent with the stated POSIX behavior, and the inspected changes support merging.

What I ran

Reviewed head c802434e3eb8b57867c2a04dd0045a75153533e6 using the prepared patch and repo_read.py. No checks were run here; the Windows test results below are author-reported.

Results

Check Result Note
Source review passed Changed implementation and integration inspected
Windows tests not run Description reports 52 guest ICU tests passed
Other host platforms not run Linux and macOS not tested

Findings

Blocking

None.

Non-blocking

None.

Not verified

Did not run the build or tests. Linux and macOS behavior, console locale selection, and the measured PS5 default locale were not verified. All changed files listed in the manifest were read or inspected through the patch: core/libs/prx/libSceIcu/CMakeLists.txt, core/libs/prx/libSceIcu/DefaultLocale.cpp, core/libs/prx/libSceIcu/Export.cpp, core/libs/prx/libSceIcu/LegacyExports.cpp, core/libs/prx/libSceIcu/include/InventoryExports.hpp, core/libs/prx/libSceIcu/include/LegacyExports.hpp, core/libs/prx/libSceIcu/tests/DefaultLocale.cpp, and docs/dev/debt/changes/feat-libSceIcu-default-locale.md. No exclusions were reported in the manifest.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5910989353 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20642#pullrequestreview-5910989353). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-15T13:39:33Z. **Review:** APPROVED --- # Reviewed — looks good The locale implementation and its focused tests are consistent with the stated POSIX behavior, and the inspected changes support merging. ## What I ran Reviewed head `c802434e3eb8b57867c2a04dd0045a75153533e6` using the prepared patch and `repo_read.py`. No checks were run here; the Windows test results below are author-reported. ## Results | Check | Result | Note | |---|---|---| | Source review | passed | Changed implementation and integration inspected | | Windows tests | not run | Description reports 52 guest ICU tests passed | | Other host platforms | not run | Linux and macOS not tested | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified Did not run the build or tests. Linux and macOS behavior, console locale selection, and the measured PS5 default locale were not verified. All changed files listed in the manifest were read or inspected through the patch: `core/libs/prx/libSceIcu/CMakeLists.txt`, `core/libs/prx/libSceIcu/DefaultLocale.cpp`, `core/libs/prx/libSceIcu/Export.cpp`, `core/libs/prx/libSceIcu/LegacyExports.cpp`, `core/libs/prx/libSceIcu/include/InventoryExports.hpp`, `core/libs/prx/libSceIcu/include/LegacyExports.hpp`, `core/libs/prx/libSceIcu/tests/DefaultLocale.cpp`, and `docs/dev/debt/changes/feat-libSceIcu-default-locale.md`. No exclusions were reported in the manifest. ## To get this to a good state Nothing is required.
MarcZX10 commented 2026-11-15 21:24:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-15T21:24:24Z.

Review: COMMENTED


Reviewed — no blocking findings

The reviewed change has no verified blocking defect; the console locale behavior remains unconfirmed, so a formal approval is not justified.

What I ran

Reviewed head 101faed024f5c14a07c9a374c1bdb5682bd162db. I read the prepared description, commits, manifest, and complete patch; I did not run commands or tests. The Windows test results are author-reported. No files were excluded in the manifest.

Results

Check Result Note
Patch and changed code review passed All changed paths inspected
Tests not run Windows results are author-reported
Console behavior not run Locale source and category are unverified

Findings

Blocking

None.

Non-blocking

  • The fallback rules and LC_MESSAGES category are modeled after ICU's POSIX path, but the debt entry says the console build's path, category value, and environment have not been confirmed. Compare the returned system locale with the console when that behavior can be measured.

Sources

  • Changed implementation: core/libs/prx/libSceIcu/DefaultLocale.cpp.
  • Changed tests: core/libs/prx/libSceIcu/tests/DefaultLocale.cpp.
  • Recorded platform limitation: docs/dev/debt/changes/feat-libSceIcu-default-locale.md.

Not verified

No build or tests were run in this review. Linux, macOS, and physical-console behavior were not verified. The changed files were core/libs/prx/libSceIcu/CMakeLists.txt, core/libs/prx/libSceIcu/DefaultLocale.cpp, core/libs/prx/libSceIcu/Export.cpp, core/libs/prx/libSceIcu/LegacyExports.cpp, core/libs/prx/libSceIcu/include/InventoryExports.hpp, core/libs/prx/libSceIcu/include/LegacyExports.hpp, core/libs/prx/libSceIcu/tests/DefaultLocale.cpp, and docs/dev/debt/changes/feat-libSceIcu-default-locale.md. I read the complete new implementation, tests, CMake additions, inventory declarations, and debt entry; for the large export files I inspected the relevant patch hunks and surrounding portions, not their entire contents. No manifest-excluded files were listed.

To get this to a good state

Nothing is required. Optional: compare the system locale behavior with a console build when available.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5912999977 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20642#pullrequestreview-5912999977). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-15T21:24:24Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The reviewed change has no verified blocking defect; the console locale behavior remains unconfirmed, so a formal approval is not justified. ## What I ran Reviewed head `101faed024f5c14a07c9a374c1bdb5682bd162db`. I read the prepared description, commits, manifest, and complete patch; I did not run commands or tests. The Windows test results are author-reported. No files were excluded in the manifest. ## Results | Check | Result | Note | |---|---|---| | Patch and changed code review | passed | All changed paths inspected | | Tests | not run | Windows results are author-reported | | Console behavior | not run | Locale source and category are unverified | ## Findings ### Blocking None. ### Non-blocking - The fallback rules and `LC_MESSAGES` category are modeled after ICU's POSIX path, but the debt entry says the console build's path, category value, and environment have not been confirmed. Compare the returned system locale with the console when that behavior can be measured. ## Sources - Changed implementation: `core/libs/prx/libSceIcu/DefaultLocale.cpp`. - Changed tests: `core/libs/prx/libSceIcu/tests/DefaultLocale.cpp`. - Recorded platform limitation: `docs/dev/debt/changes/feat-libSceIcu-default-locale.md`. ## Not verified No build or tests were run in this review. Linux, macOS, and physical-console behavior were not verified. The changed files were `core/libs/prx/libSceIcu/CMakeLists.txt`, `core/libs/prx/libSceIcu/DefaultLocale.cpp`, `core/libs/prx/libSceIcu/Export.cpp`, `core/libs/prx/libSceIcu/LegacyExports.cpp`, `core/libs/prx/libSceIcu/include/InventoryExports.hpp`, `core/libs/prx/libSceIcu/include/LegacyExports.hpp`, `core/libs/prx/libSceIcu/tests/DefaultLocale.cpp`, and `docs/dev/debt/changes/feat-libSceIcu-default-locale.md`. I read the complete new implementation, tests, CMake additions, inventory declarations, and debt entry; for the large export files I inspected the relevant patch hunks and surrounding portions, not their entire contents. No manifest-excluded files were listed. ## To get this to a good state Nothing is required. Optional: compare the system locale behavior with a console build when available.
MarcZX10 commented 2026-11-16 01:07:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-16T01:07:39Z.

Review: COMMENTED


Reviewed — comments

The change adds default locale lookup and reset behavior at the stated head; I found one compatibility concern to share, and the console locale behavior remains unverified.

What I ran

Reviewed head d53f4471c756792fcd7adc6d0788b3e430ccf086. No commands or tests were run; I inspected the prepared diff and source through the pinned reader. The author reports five new Windows scenarios and 52 guest ICU tests passed; those results were not run by this review.

Results

Check Result Note
Diff and changed source review passed All changed files were read
Automated checks not run Author-reported Windows results only

Findings

Blocking

None.

Non-blocking

  • uloc_setDefault(nullptr, status) appears to re-canonicalize the system locale on each reset, while the implemented system default itself is cached. ICU’s reset path returns to its established system default. Consider caching the canonicalized system default as well, so resets remain consistent if locale state changes through another path. Changed line: core/libs/prx/libSceIcu/DefaultLocale.cpp:127.

Not verified

The actual console default locale and whether the console follows this POSIX branch were not verified. Linux and macOS builds were not run. No checks were run in this review. All changed files marked reviewed in the manifest were read: core/libs/prx/libSceIcu/CMakeLists.txt, core/libs/prx/libSceIcu/DefaultLocale.cpp, core/libs/prx/libSceIcu/Export.cpp, core/libs/prx/libSceIcu/LegacyExports.cpp, core/libs/prx/libSceIcu/include/InventoryExports.hpp, core/libs/prx/libSceIcu/include/LegacyExports.hpp, core/libs/prx/libSceIcu/tests/DefaultLocale.cpp, and docs/dev/debt/changes/feat-libSceIcu-default-locale.md. No files were excluded by the prepared review folder.

To get this to a good state

Nothing is required. Optional: preserve the cached canonical system default when resetting the current default.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5913954540 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20642#pullrequestreview-5913954540). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-16T01:07:39Z. **Review:** COMMENTED --- # Reviewed — comments The change adds default locale lookup and reset behavior at the stated head; I found one compatibility concern to share, and the console locale behavior remains unverified. ## What I ran Reviewed head `d53f4471c756792fcd7adc6d0788b3e430ccf086`. No commands or tests were run; I inspected the prepared diff and source through the pinned reader. The author reports five new Windows scenarios and 52 guest ICU tests passed; those results were not run by this review. ## Results | Check | Result | Note | |---|---|---| | Diff and changed source review | passed | All changed files were read | | Automated checks | not run | Author-reported Windows results only | ## Findings ### Blocking None. ### Non-blocking - `uloc_setDefault(nullptr, status)` appears to re-canonicalize the system locale on each reset, while the implemented system default itself is cached. ICU’s reset path returns to its established system default. Consider caching the canonicalized system default as well, so resets remain consistent if locale state changes through another path. Changed line: `core/libs/prx/libSceIcu/DefaultLocale.cpp:127`. ## Not verified The actual console default locale and whether the console follows this POSIX branch were not verified. Linux and macOS builds were not run. No checks were run in this review. All changed files marked reviewed in the manifest were read: `core/libs/prx/libSceIcu/CMakeLists.txt`, `core/libs/prx/libSceIcu/DefaultLocale.cpp`, `core/libs/prx/libSceIcu/Export.cpp`, `core/libs/prx/libSceIcu/LegacyExports.cpp`, `core/libs/prx/libSceIcu/include/InventoryExports.hpp`, `core/libs/prx/libSceIcu/include/LegacyExports.hpp`, `core/libs/prx/libSceIcu/tests/DefaultLocale.cpp`, and `docs/dev/debt/changes/feat-libSceIcu-default-locale.md`. No files were excluded by the prepared review folder. ## To get this to a good state Nothing is required. Optional: preserve the cached canonical system default when resetting the current default.
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!20642
No description provided.