feat(libSceIcu): implement the invariant character and version helpers #11013

Merged
mantavisual merged 2 commits from upstream-pr/11013 into main 2026-10-26 16:37:26 +00:00
mantavisual commented 2026-10-25 14:11:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mantavisual on 2026-10-25T14:11:55Z.


What

Implements five libSceIcu exports from the PS5 3.20 export table: u_charsToUChars, u_UCharsToChars, u_versionFromString, u_versionFromUString and u_versionToString. None of them needs Unicode data, and their bodies are the same in every ICU release from 65.1 to 78.1.

Firmware 13.42's libSceIcu.sprx reports ICU 78.1 and exports none of these five (measured by BunnyFl). The PS5 3.20 export table exports all five, and its markers point to ICU 65–68 for that firmware: it has uloc_openAvailableByType (ICU 65) and lacks ubrk_clone (69), u_stringHasBinaryProperty (70) and ucnv_clone (71). The code follows ICU 78.1's uinvchar.cpp and putil.cpp. I compared the five bodies in 65.1, 66.1, 67.1, 68.1, 68.2, 72.1 and 78.1; they differ only in NULL/nullptr, UChar/char16_t and FALSE/false, so the code is the same for either firmware. ICU 64's u_UCharsToChars differs, but neither firmware uses 64.

  • u_charsToUChars widens each byte without sign extension.
  • u_UCharsToChars keeps the ICU invariant set (ASCII except LF, !#$@[\]^ and `{|}~) and writes NUL for every other code unit.
  • u_versionFromString reads up to four .-separated parts with strtoul (the guest libc's strtoul_nid_postfix, base 10) and truncates each to eight bits. Parsing stops at an empty part or another character, and missing parts become 0. A null string clears the version, and a null version does nothing.
  • u_versionFromUString reads at most 20 code units, narrows them as u_UCharsToChars does, and parses the result. A null string or version leaves the version unchanged.
  • u_versionToString writes at least two parts and omits trailing zero parts. It keeps ICU's digit writer, which drops a zero tens digit after a hundreds digit: 105 becomes 15 and 100 becomes 10. A null version writes an empty string, and a null buffer does nothing.

A null buffer with a positive length in either conversion throws APS5_INVALID_ARG_EX, since ICU dereferences it. The new docs/dev/debt/libSceIcu.md entry records that none of this is checked on a console, and the 13.42 version and exports (second commit, 37d5137ea0).

The layout follows #10961–#10967 (a CMakeLists.txt for the library, one header per source included from libSceIcu.hpp). Those PRs implement other ICU functions and none of these five, but each adds CMakeLists.txt, libSceIcu.hpp and the debt file, so whichever merges second needs a small rebase.

Tested

Windows 11 Pro 23H2, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON, on main e05ba6feeb.

  • New guest_icu_version:
    • All 256 bytes widen to 0–255.
    • All 65536 code units narrow to themselves or NUL according to an independently written invariant list.
    • Nonpositive lengths write nothing; null buffers with a zero length are accepted, and with a positive length they throw.
    • u_versionFromString covers four or five parts, empty and digitless strings, stops at x and .., trailing ., leading spaces, +5.-1 → 5.255, 256.300.511 → 0.44.255, overflow → 255, and null arguments.
    • u_versionFromUString covers variant, non-ASCII and fullwidth characters, the 20-unit limit (20 units read, the 21st ignored), and null arguments.
    • u_versionToString covers trailing and inner zeros, 0.0, 7.0, 100.105.109.110 → 10.15.19.110, a null version and a null buffer; it never writes past the NUL. A round trip covers every part value the digit writer preserves.
  • ctest -R "guest_icu_version|patched_libraries": both pass. The NID-patched libSceIcu.prx builds, and its export table has the five NIDs.
  • tools/progress.py --module libSceIcu: 5 implemented, 0 stubs. tools/check_test_registration.py build: 1341 test executables, none built and not run.
  • python3 tools/check_conventions.py --base origin/main passes. Overlap: no open PR implements or names these five functions (checked 2026-10-25, including the diffs of #10961–#10967).

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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5005490436 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11013). Originally posted by [mantavisual](https://github.com/mantavisual) on 2026-10-25T14:11:55Z. --- ### What Implements five `libSceIcu` exports from the [PS5 3.20 export table](https://github.com/DNNDHH/PS5-3.20_Libs/blob/b2a77c09cd71c01f34c790cfbe98c751a13262ad/libSceIcu.c): `u_charsToUChars`, `u_UCharsToChars`, `u_versionFromString`, `u_versionFromUString` and `u_versionToString`. None of them needs Unicode data, and their bodies are the same in every ICU release from 65.1 to 78.1. Firmware 13.42's `libSceIcu.sprx` reports ICU 78.1 and exports none of these five ([measured by BunnyFl](https://github.com/boykopovar/AnyPS5/pull/11013#issuecomment-6400470698)). The [PS5 3.20 export table](https://github.com/DNNDHH/PS5-3.20_Libs/blob/b2a77c09cd71c01f34c790cfbe98c751a13262ad/libSceIcu.c) exports all five, and its markers point to ICU 65–68 for that firmware: it has `uloc_openAvailableByType` (ICU 65) and lacks `ubrk_clone` (69), `u_stringHasBinaryProperty` (70) and `ucnv_clone` (71). The code follows ICU 78.1's [uinvchar.cpp](https://github.com/unicode-org/icu/blob/release-78.1/icu4c/source/common/uinvchar.cpp) and [putil.cpp](https://github.com/unicode-org/icu/blob/release-78.1/icu4c/source/common/putil.cpp). I compared the five bodies in 65.1, 66.1, 67.1, 68.1, 68.2, 72.1 and 78.1; they differ only in `NULL`/`nullptr`, `UChar`/`char16_t` and `FALSE`/`false`, so the code is the same for either firmware. ICU 64's `u_UCharsToChars` differs, but neither firmware uses 64. - `u_charsToUChars` widens each byte without sign extension. - `u_UCharsToChars` keeps the ICU invariant set (ASCII except LF, `!#$@[\]^` and `` `{|}~ ``) and writes NUL for every other code unit. - `u_versionFromString` reads up to four `.`-separated parts with `strtoul` (the guest libc's `strtoul_nid_postfix`, base 10) and truncates each to eight bits. Parsing stops at an empty part or another character, and missing parts become 0. A null string clears the version, and a null version does nothing. - `u_versionFromUString` reads at most 20 code units, narrows them as `u_UCharsToChars` does, and parses the result. A null string or version leaves the version unchanged. - `u_versionToString` writes at least two parts and omits trailing zero parts. It keeps ICU's digit writer, which drops a zero tens digit after a hundreds digit: 105 becomes `15` and 100 becomes `10`. A null version writes an empty string, and a null buffer does nothing. A null buffer with a positive length in either conversion throws `APS5_INVALID_ARG_EX`, since ICU dereferences it. The new `docs/dev/debt/libSceIcu.md` entry records that none of this is checked on a console, and the 13.42 version and exports (second commit, `37d5137ea0`). The layout follows #10961–#10967 (a `CMakeLists.txt` for the library, one header per source included from `libSceIcu.hpp`). Those PRs implement other ICU functions and none of these five, but each adds `CMakeLists.txt`, `libSceIcu.hpp` and the debt file, so whichever merges second needs a small rebase. ### Tested Windows 11 Pro 23H2, WinLibs GCC 15.2.0 r7, Release, `BUILD_TESTING=ON`, on `main` `e05ba6feeb`. - New `guest_icu_version`: - All 256 bytes widen to 0–255. - All 65536 code units narrow to themselves or NUL according to an independently written invariant list. - Nonpositive lengths write nothing; null buffers with a zero length are accepted, and with a positive length they throw. - `u_versionFromString` covers four or five parts, empty and digitless strings, stops at `x` and `..`, trailing `.`, leading spaces, `+5.-1` → 5.255, `256.300.511` → 0.44.255, overflow → 255, and null arguments. - `u_versionFromUString` covers variant, non-ASCII and fullwidth characters, the 20-unit limit (20 units read, the 21st ignored), and null arguments. - `u_versionToString` covers trailing and inner zeros, `0.0`, `7.0`, `100.105.109.110` → `10.15.19.110`, a null version and a null buffer; it never writes past the NUL. A round trip covers every part value the digit writer preserves. - `ctest -R "guest_icu_version|patched_libraries"`: both pass. The NID-patched `libSceIcu.prx` builds, and its export table has the five NIDs. - `tools/progress.py --module libSceIcu`: 5 implemented, 0 stubs. `tools/check_test_registration.py build`: 1341 test executables, none built and not run. - `python3 tools/check_conventions.py --base origin/main` passes. Overlap: no open PR implements or names these five functions (checked 2026-10-25, including the diffs of #10961–#10967). ### 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
MarcZX10 commented 2026-10-25 14:14:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T14:14:36Z.

Review: APPROVED


Reviewed the implementations against ICU 68.2. The invariant character table matches ICU’s bit masks; the conversion loops preserve the full unsigned byte range, replace variant UTF-16 units with NUL, and respect nonpositive lengths. The version parser follows ICU’s strtoul/delimiter/part-count logic, including null handling and zero-fill, while the formatter preserves ICU’s two-field minimum and digit-writer behavior. I checked the new tests and ran C++20 syntax checks on all three changed translation units; conventions and diff checks pass. The author reports the exhaustive 65,536-code-unit test and focused Windows test pass. Console behavior remains unverified as documented.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5643622365 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11013#pullrequestreview-5643622365). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-25T14:14:36Z. **Review:** APPROVED --- Reviewed the implementations against ICU 68.2. The invariant character table matches ICU’s bit masks; the conversion loops preserve the full unsigned byte range, replace variant UTF-16 units with NUL, and respect nonpositive lengths. The version parser follows ICU’s `strtoul`/delimiter/part-count logic, including null handling and zero-fill, while the formatter preserves ICU’s two-field minimum and digit-writer behavior. I checked the new tests and ran C++20 syntax checks on all three changed translation units; conventions and diff checks pass. The author reports the exhaustive 65,536-code-unit test and focused Windows test pass. Console behavior remains unverified as documented.
MarcZX10 commented 2026-10-25 15:22:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T15:22:06Z.

Review: CHANGES_REQUESTED


The function review remains positive, but this head has an unresolved repository merge-order item. Its new CMakeLists.txt, umbrella header and debt file overlap #10961–#10967. AZLisme has proposed that #11013 merge first, followed by their disjoint-function series, and provided local combined-build/test evidence; I do not see an acceptance from this PR’s author yet. Please confirm or propose another order in the thread, and record any required Depends on entry. This follows CONTRIBUTING.md’s requirement to agree on order for overlapping PRs. No code correction is requested.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5643843665 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11013#pullrequestreview-5643843665). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-25T15:22:06Z. **Review:** CHANGES_REQUESTED --- The function review remains positive, but this head has an unresolved repository merge-order item. Its new `CMakeLists.txt`, umbrella header and debt file overlap #10961–#10967. AZLisme has proposed that #11013 merge first, followed by their disjoint-function series, and provided local combined-build/test evidence; I do not see an acceptance from this PR’s author yet. Please confirm or propose another order in the thread, and record any required `Depends on` entry. This follows CONTRIBUTING.md’s requirement to agree on order for overlapping PRs. No code correction is requested.
MarcZX10 commented 2026-10-25 17:27:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T17:27:07Z.

Review: APPROVED


I rechecked the merge-order thread: mantavisual agreed to merge this PR first and to keep Depends on: none, and AZLisme recorded the follow-up sequence starting at #10961. The prior blocker is resolved. The implementation and test review remains positive; the reported focused Windows run and the independent combined Linux ICU test report cover the added helpers. Current exact-head eligibility, conventions, intake, labels and report checks pass; platform product jobs are skipped by path policy. Approved.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5644344877 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11013#pullrequestreview-5644344877). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-25T17:27:07Z. **Review:** APPROVED --- I rechecked the merge-order thread: mantavisual agreed to merge this PR first and to keep `Depends on: none`, and AZLisme recorded the follow-up sequence starting at #10961. The prior blocker is resolved. The implementation and test review remains positive; the reported focused Windows run and the independent combined Linux ICU test report cover the added helpers. Current exact-head eligibility, conventions, intake, labels and report checks pass; platform product jobs are skipped by path policy. Approved.
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!11013
No description provided.