feat(libSceIcu): implement uloc_forLanguageTag #16872

Merged
ashwin280802 merged 2 commits from upstream-pr/16872 into main 2026-11-11 15:01:06 +00:00
ashwin280802 commented 2026-11-07 19:29:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ashwin280802 on 2026-11-07T19:29:44Z.


What

Implements uloc_forLanguageTag in libSceIcu, following ICU 68.2 uloc_tag.cpp. It parses a BCP 47 tag into an ICU locale ID, reports the parsed length and the status, and keeps ICU's _POSIX suffix after the variants when a non-u extension or private use follows a variant (ICU 74 no longer writes it).

A -u- extension with a key throws through NotImplemented_nid_no_patch: ICU maps keys and types through the keyTypeData resource, which no host library provides. This and the missing console comparison are recorded in docs/dev/debt/libSceIcu.md. uloc_toLanguageTag is not part of this change.

Open PR overlap: PR 16507 and PR 16611 also edit core/libs/prx/libSceIcu/CMakeLists.txt near line 12 (source list, no shared export). The overlap check could not compare 9 other open PRs that conflict with main (10964, 10965, 10966, 10967, 12738, 13578, 14123, 14212, 16250), so I make no claim of zero overlap with them.

Tested

Windows 11, MinGW GCC (WinLibs) build in build-full, commit 8c8105ea0c.

ctest --test-dir build-full -R guest_icu, including the new guest_icu_language_tag:

25/26 Test #2926: guest_icu_character ....................   Passed    0.01 sec
26/26 Test #2927: guest_icu_configuration ................   Passed    0.01 sec
100% tests passed out of 26

I changed 20 conditions one at a time and the new test failed on all 20.

python3 tools/check_conventions.py --base origin/main:

All conventions checks passed.

Not covered by a test: the -u- keyword mapping (not implemented; the throw is tested), and agreement with a console.

Not verified: behaviour on a console. The wider libSceIcu and NKWebKit run (65 tests, Windows and Linux in Docker, all passed) ran on commit d80cd25375, not on this commit; the commits after it change only the technical debt file, so the code and tests are identical.

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
  • 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

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5205118084 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16872). Originally posted by [ashwin280802](https://github.com/ashwin280802) on 2026-11-07T19:29:44Z. --- ### What Implements `uloc_forLanguageTag` in libSceIcu, following ICU 68.2 [uloc_tag.cpp](https://github.com/unicode-org/icu/blob/84e1f26ea77152936e70d53178a816dbfbf69989/icu4c/source/common/uloc_tag.cpp). It parses a BCP 47 tag into an ICU locale ID, reports the parsed length and the status, and keeps ICU's `_POSIX` suffix after the variants when a non-`u` extension or private use follows a variant (ICU 74 no longer writes it). A `-u-` extension with a key throws through `NotImplemented_nid_no_patch`: ICU maps keys and types through the `keyTypeData` resource, which no host library provides. This and the missing console comparison are recorded in `docs/dev/debt/libSceIcu.md`. `uloc_toLanguageTag` is not part of this change. Open PR overlap: PR 16507 and PR 16611 also edit `core/libs/prx/libSceIcu/CMakeLists.txt` near line 12 (source list, no shared export). The overlap check could not compare 9 other open PRs that conflict with `main` (10964, 10965, 10966, 10967, 12738, 13578, 14123, 14212, 16250), so I make no claim of zero overlap with them. ### Tested Windows 11, MinGW GCC (WinLibs) build in `build-full`, commit 8c8105ea0c. `ctest --test-dir build-full -R guest_icu`, including the new `guest_icu_language_tag`: ``` 25/26 Test #2926: guest_icu_character .................... Passed 0.01 sec 26/26 Test #2927: guest_icu_configuration ................ Passed 0.01 sec 100% tests passed out of 26 ``` I changed 20 conditions one at a time and the new test failed on all 20. `python3 tools/check_conventions.py --base origin/main`: ``` All conventions checks passed. ``` Not covered by a test: the `-u-` keyword mapping (not implemented; the throw is tested), and agreement with a console. Not verified: behaviour on a console. The wider libSceIcu and NKWebKit run (65 tests, Windows and Linux in Docker, all passed) ran on commit d80cd25375, not on this commit; the commits after it change only the technical debt file, so the code and tests are identical. ### 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) - [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 🤖 Generated with [Claude Code](https://claude.com/claude-code)
gabichuuuuu commented 2026-11-07 22:07:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by gabichuuuuu on 2026-11-07T22:07:10Z.

Review: COMMENTED


Read 4ef6d81f0c against main.

I compared LanguageTag.cpp with ICU 68.2 uloc_tag.cpp (ultag_parse, _appendKeywords, _appendLDMLExtensionAsKeywords, uloc_forLanguageTag): the legacy and redundant tables and their order (zh-min-nan before zh-min), the subtag state machine, lvariant handling, the parsed-length delta (i-default gives 9, cel-gaulish 11), the 100-byte attribute limit, ICU 68's _POSIX rule (en-fonipa-t-ab gives en__FONIPA_POSIX@t=ab), and the overflow, not-terminated and negative-capacity results. They match; I found no defect. Throwing for -u- keys before anything is written, and for null arguments, fits the project rules, and the new test can't pass on main, where the stub has no parameters and throws.

One thing outside the code: the PR follows ICU 68.2 deliberately, while other entries in the same debt file follow ICU 78.1, which firmware 13.42 reports. The debt entry already records that, and which one titles see is a firmware question, not a defect here.

Not run here; this is from reading the code.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5815219497 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16872#pullrequestreview-5815219497). Originally posted by [gabichuuuuu](https://github.com/gabichuuuuu) on 2026-11-07T22:07:10Z. **Review:** COMMENTED --- Read `4ef6d81f0c` against `main`. I compared `LanguageTag.cpp` with ICU 68.2 `uloc_tag.cpp` (`ultag_parse`, `_appendKeywords`, `_appendLDMLExtensionAsKeywords`, `uloc_forLanguageTag`): the legacy and redundant tables and their order (`zh-min-nan` before `zh-min`), the subtag state machine, `lvariant` handling, the parsed-length delta (`i-default` gives 9, `cel-gaulish` 11), the 100-byte attribute limit, ICU 68's `_POSIX` rule (`en-fonipa-t-ab` gives `en__FONIPA_POSIX@t=ab`), and the overflow, not-terminated and negative-capacity results. They match; I found no defect. Throwing for `-u-` keys before anything is written, and for null arguments, fits the project rules, and the new test can't pass on `main`, where the stub has no parameters and throws. One thing outside the code: the PR follows ICU 68.2 deliberately, while other entries in the same debt file follow ICU 78.1, which firmware 13.42 reports. The debt entry already records that, and which one titles see is a firmware question, not a defect here. Not run here; this is from reading the code. AI-assisted: yes.
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!16872
No description provided.