feat(libSceIcu): implement the resource UTF-8 accessors #24357

Merged
larpsahur333 merged 1 commit from upstream-pr/24357 into main 2026-11-21 14:30:59 +00:00
larpsahur333 commented 2026-11-20 15:05:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by larpsahur333 on 2026-11-20T15:05:50Z.


What

Three libSceIcu exports that answered NotImplemented_nid_no_patch now read the ICU 68.2 resource string layout and convert it to UTF-8:

  • ures_getUTF8String - the bundle's own string resource
  • ures_getUTF8StringByIndex - a string from an array or table slot, or a top-level string at index 0
  • ures_getUTF8StringByKey - a string from a table entry

They follow ICU's ures_toUTF8String: the UTF-16 units are read from pRoot + offset*4, capacity and pLength are copied in and out, a negative capacity or a positive capacity with a null destination is U_ILLEGAL_ARGUMENT_ERROR, an undersized buffer is preflighted with U_BUFFER_OVERFLOW_ERROR, forceCopy keeps the output at dest while a false value may place it at the tail of the buffer, and an empty string returns the empty pointer. A non-string resource reports U_RESOURCE_TYPE_MISMATCH, a missing key or index U_MISSING_RESOURCE_ERROR, and a null pRoot U_UNSUPPORTED_ERROR.

Pool bundles and fallback chains remain unsupported, and the base ures_getString* exports are still stubs, so these read the bundle layout directly.

Tested

guest_icu_resource_utf8 (core/libs/prx/libSceIcu/tests/ResourceUtf8.cpp) passes. It builds synthetic 200-byte bundles and a synthetic resource pool, so no icudt data is needed:

  • ures_getUTF8String copies "hi", preflights a zero capacity (status 15, length 2), keeps forceCopy at dest, places the string at the tail when forceCopy is false, reports U_STRING_NOT_TERMINATED_WARNING for an exact-size buffer, terminates an empty string, and rejects an array, a null bundle and a negative capacity
  • ures_getUTF8StringByIndex returns the two array strings, the table value and a top-level string, and reports U_MISSING_RESOURCE_ERROR past the end and for a negative index
  • ures_getUTF8StringByKey returns the keyed table string and reports U_MISSING_RESOURCE_ERROR for a missing or null key and U_RESOURCE_TYPE_MISMATCH for an array
  • a null status returns null

python core/libs/tests/test_public_headers.py --compiler g++ reports 413 libraries, 34735 exports: unique declarations and umbrella coverage verified.

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
  • 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
  • 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:5415536185 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24357). Originally posted by [larpsahur333](https://github.com/larpsahur333) on 2026-11-20T15:05:50Z. --- ### What Three `libSceIcu` exports that answered `NotImplemented_nid_no_patch` now read the ICU 68.2 resource string layout and convert it to UTF-8: - `ures_getUTF8String` - the bundle's own string resource - `ures_getUTF8StringByIndex` - a string from an array or table slot, or a top-level string at index 0 - `ures_getUTF8StringByKey` - a string from a table entry They follow ICU's `ures_toUTF8String`: the UTF-16 units are read from `pRoot + offset*4`, `capacity` and `pLength` are copied in and out, a negative capacity or a positive capacity with a null destination is `U_ILLEGAL_ARGUMENT_ERROR`, an undersized buffer is preflighted with `U_BUFFER_OVERFLOW_ERROR`, `forceCopy` keeps the output at `dest` while a false value may place it at the tail of the buffer, and an empty string returns the empty pointer. A non-string resource reports `U_RESOURCE_TYPE_MISMATCH`, a missing key or index `U_MISSING_RESOURCE_ERROR`, and a null `pRoot` `U_UNSUPPORTED_ERROR`. Pool bundles and fallback chains remain unsupported, and the base `ures_getString*` exports are still stubs, so these read the bundle layout directly. ### Tested `guest_icu_resource_utf8` (`core/libs/prx/libSceIcu/tests/ResourceUtf8.cpp`) passes. It builds synthetic 200-byte bundles and a synthetic resource pool, so no `icudt` data is needed: - `ures_getUTF8String` copies `"hi"`, preflights a zero capacity (status 15, length 2), keeps `forceCopy` at `dest`, places the string at the tail when `forceCopy` is false, reports `U_STRING_NOT_TERMINATED_WARNING` for an exact-size buffer, terminates an empty string, and rejects an array, a null bundle and a negative capacity - `ures_getUTF8StringByIndex` returns the two array strings, the table value and a top-level string, and reports `U_MISSING_RESOURCE_ERROR` past the end and for a negative index - `ures_getUTF8StringByKey` returns the keyed table string and reports `U_MISSING_RESOURCE_ERROR` for a missing or null key and `U_RESOURCE_TYPE_MISMATCH` for an array - a null status returns null `python core/libs/tests/test_public_headers.py --compiler g++` reports `413 libraries, 34735 exports: unique declarations and umbrella coverage verified`. ### 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 and the licence notice of code adapted from upstream - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's technical debt file - [x] No notes, investigation `.md` files or images added to the repository - [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-20 15:17:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T15:17:56Z.

Review: COMMENTED


Reviewed — comments

The review folder and repository files could not be read in this environment, so the change is not verified and no formal approval or change request is justified.

What I ran

Not run. No reader or shell tool is available in this session.

Results

Check Result Note
Review folder inspection not run Reader unavailable
Changed code audit not run Files not read

Findings

Blocking

None verified.

Non-blocking

Review is incomplete because the prepared review materials and changed files could not be inspected.

Not verified

The description, commits, diff, manifest, changed files, and repository context were not read. Files read: none. Files listed for review: not verified.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5994980902 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24357#pullrequestreview-5994980902). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T15:17:56Z. **Review:** COMMENTED --- # Reviewed — comments The review folder and repository files could not be read in this environment, so the change is not verified and no formal approval or change request is justified. ## What I ran Not run. No reader or shell tool is available in this session. ## Results | Check | Result | Note | |---|---|---| | Review folder inspection | not run | Reader unavailable | | Changed code audit | not run | Files not read | ## Findings ### Blocking None verified. ### Non-blocking Review is incomplete because the prepared review materials and changed files could not be inspected. ## Not verified The description, commits, diff, manifest, changed files, and repository context were not read. Files read: none. Files listed for review: not verified. ## To get this to a good state Nothing is required.
PrivacyOnion commented 2026-11-20 15:35:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-20T15:35:40Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 4fae6fceab:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_icu_resource_utf8_tests built cleanly.
  • CTest (guest_icu_resource_utf8):
    1/1 Test #4050: guest_icu_resource_utf8 ..........   Passed    0.03 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceIcu/LegacyExports.cpp, core/libs/prx/libSceIcu/RecoveredSignatures.hpp, core/libs/prx/libSceIcu/include/LegacyExports.hpp, core/libs/prx/libSceIcu/ResourceUtf8.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • core/libs/prx/libSceIcu/ResourceUtf8.cpp: Checked guest pointer operations (CopyIn, CopyOut, ReadGuestString) for all parameters (resB, dest, length, status, key) and validated error propagation and bounds handling.
    • core/libs/prx/libSceIcu/ResourceUtf8.cpp: Verified ICU error codes matching U_ILLEGAL_ARGUMENT_ERROR (1), U_MISSING_RESOURCE_ERROR (2), U_BUFFER_OVERFLOW_ERROR (15), U_UNSUPPORTED_ERROR (16), U_RESOURCE_TYPE_MISMATCH (17), and U_STRING_NOT_TERMINATED_WARNING (-124).
    • core/libs/prx/libSceIcu/ResourceUtf8.cpp: Verified handling of forceCopy, non-forceCopy tail-placement offset calculation, zero capacity, and empty string special cases against upstream ures_toUTF8String.
    • core/libs/prx/libSceIcu/ResourceUtf8.cpp: Verified Resource offset, Root offset, Size offset, TypeShift, ValueMask, and table key binary/linear scanning logic.
    • core/libs/prx/libSceIcu/tests/ResourceUtf8.cpp: Verified test coverage including preflighting, under-capacity truncation protection, termination guarantees, negative capacity, and key/index boundary checks.
    • docs/dev/debt/changes/feat-icu-unclaimed.md: Verified technical debt fragment format, classification, and completeness.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5995225863 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24357#pullrequestreview-5995225863). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-20T15:35:40Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `4fae6fceab`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_icu_resource_utf8_tests` built cleanly. - **CTest** (`guest_icu_resource_utf8`): ``` 1/1 Test #4050: guest_icu_resource_utf8 .......... Passed 0.03 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceIcu/LegacyExports.cpp`, `core/libs/prx/libSceIcu/RecoveredSignatures.hpp`, `core/libs/prx/libSceIcu/include/LegacyExports.hpp`, `core/libs/prx/libSceIcu/ResourceUtf8.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - core/libs/prx/libSceIcu/ResourceUtf8.cpp: Checked guest pointer operations (CopyIn, CopyOut, ReadGuestString) for all parameters (resB, dest, length, status, key) and validated error propagation and bounds handling. - core/libs/prx/libSceIcu/ResourceUtf8.cpp: Verified ICU error codes matching U_ILLEGAL_ARGUMENT_ERROR (1), U_MISSING_RESOURCE_ERROR (2), U_BUFFER_OVERFLOW_ERROR (15), U_UNSUPPORTED_ERROR (16), U_RESOURCE_TYPE_MISMATCH (17), and U_STRING_NOT_TERMINATED_WARNING (-124). - core/libs/prx/libSceIcu/ResourceUtf8.cpp: Verified handling of forceCopy, non-forceCopy tail-placement offset calculation, zero capacity, and empty string special cases against upstream ures_toUTF8String. - core/libs/prx/libSceIcu/ResourceUtf8.cpp: Verified Resource offset, Root offset, Size offset, TypeShift, ValueMask, and table key binary/linear scanning logic. - core/libs/prx/libSceIcu/tests/ResourceUtf8.cpp: Verified test coverage including preflighting, under-capacity truncation protection, termination guarantees, negative capacity, and key/index boundary checks. - docs/dev/debt/changes/feat-icu-unclaimed.md: Verified technical debt fragment format, classification, and completeness. Looks Good To Me
MarcZX10 commented 2026-11-20 16:33:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T16:33:05Z.

Review: COMMENTED


Reviewed — no blocking findings

The implementation and all changed lines listed in the manifest were inspected at head 706b3dfe812da0c60938468ba94ecd01420879d1; the author reports passing tests, but I did not run them.

What I ran

No commands or tests were run. I read the prepared description, commit summary, diff, manifest, and all changed files’ added lines; I also inspected the implementation and test source.

Results

Check Result Note
Source review passed Changed lines inspected
PR tests not run Author-reported results only
Build and runtime not run Not independently checked

Negative control

Not run; no test execution was available in this review.

Findings

Blocking

None.

Non-blocking

None.

Sources

Not verified

The author reports that guest_icu_resource_utf8 and the public-header check passed; I did not run or independently verify either. Build and console behavior were not checked. All seven changed files in the manifest were included; all files with added lines were read, while the two changed files with no added lines were inspected through the diff only.

To get this to a good state

Nothing is required. Optional: confirm the reported test results in CI.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5996027840 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24357#pullrequestreview-5996027840). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T16:33:05Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The implementation and all changed lines listed in the manifest were inspected at head `706b3dfe812da0c60938468ba94ecd01420879d1`; the author reports passing tests, but I did not run them. ## What I ran No commands or tests were run. I read the prepared description, commit summary, diff, manifest, and all changed files’ added lines; I also inspected the implementation and test source. ## Results | Check | Result | Note | |---|---|---| | Source review | passed | Changed lines inspected | | PR tests | not run | Author-reported results only | | Build and runtime | not run | Not independently checked | ## Negative control Not run; no test execution was available in this review. ## Findings ### Blocking None. ### Non-blocking None. ## Sources - [ResourceUtf8.cpp at the reviewed commit](https://github.com/boykopovar/AnyPS5/blob/706b3dfe812da0c60938468ba94ecd01420879d1/core/libs/prx/libSceIcu/ResourceUtf8.cpp) - [ResourceUtf8.cpp tests at the reviewed commit](https://github.com/boykopovar/AnyPS5/blob/706b3dfe812da0c60938468ba94ecd01420879d1/core/libs/prx/libSceIcu/tests/ResourceUtf8.cpp) ## Not verified The author reports that `guest_icu_resource_utf8` and the public-header check passed; I did not run or independently verify either. Build and console behavior were not checked. All seven changed files in the manifest were included; all files with added lines were read, while the two changed files with no added lines were inspected through the diff only. ## To get this to a good state Nothing is required. Optional: confirm the reported test results in CI.
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!24357
No description provided.