feat(libSceIcu): implement the ucnv converter name queries #24274

Merged
Callimann8 merged 1 commit from upstream-pr/24274 into main 2026-11-21 13:08:21 +00:00
Callimann8 commented 2026-11-20 12:53:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Callimann8 on 2026-11-20T12:53:13Z.


What

Implements six converter name queries in libSceIcu that were throwing stubs in LegacyExports.cpp: ucnv_countAvailable, ucnv_getAvailableName, ucnv_countAliases, ucnv_getAlias, ucnv_countStandards and ucnv_getStandardName. These are the calls WebKit's ICU text codec uses to build its encoding name table, so a web view that registers encodings no longer stops on the first one.

They sit next to ucnv_getAliases in ConverterAliases.cpp and forward to the bundled ICU, following the same pattern:

  • ucnv_countAvailable, ucnv_getAvailableName and ucnv_countStandards take no guest pointers and return ICU's result directly.
  • ucnv_countAliases, ucnv_getAlias and ucnv_getStandardName read the status with a checked copy and return 0 or null without touching other arguments when it already holds a failure. Otherwise they check the status is writable, copy the alias, converter and standard names in through checked guest reads (null stays null), call ICU and write back a changed status.
  • A null status throws std::invalid_argument; unreadable names or status throw through NotImplemented_nid_no_patch.
  • Returned strings are ICU-owned process-lifetime storage, borrowed the same way ucnv_getAliases already returns them.

The bundled ICU data package omits cnvalias.icu, so today these report zero converters, zero standards or U_FILE_ACCESS_ERROR instead of throwing. The new debt fragment records that and that the console prototypes are unverified.

Tested

Linux (Ubuntu 24.04, GCC 13.3). guest_icu_converter_aliases gains a NameQueries case: signature checks, parity with the pinned ICU for every function across in- and out-of-range indexes, null, empty, valid, fuzzy-matched, unknown and over-long names, several standards and five incoming status values, guest readability of returned strings, null status, unreadable status, a status that is already a failure, and unreadable name and standard pointers. The test passes in a Release build and in an ASan + UBSan build (ANYPS5_ENABLE_ASAN=ON, -fsanitize=undefined); guest_icu_converter_available_names, guest_icu_converter_canonical_name and guest_icu_converter_helpers also pass. Only libSceIcu changed, so the full emulator build was skipped. Not tested on a console.

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:5413650660 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24274). Originally posted by [Callimann8](https://github.com/Callimann8) on 2026-11-20T12:53:13Z. --- ### What Implements six converter name queries in libSceIcu that were throwing stubs in `LegacyExports.cpp`: `ucnv_countAvailable`, `ucnv_getAvailableName`, `ucnv_countAliases`, `ucnv_getAlias`, `ucnv_countStandards` and `ucnv_getStandardName`. These are the calls WebKit's ICU text codec uses to build its encoding name table, so a web view that registers encodings no longer stops on the first one. They sit next to `ucnv_getAliases` in `ConverterAliases.cpp` and forward to the bundled ICU, following the same pattern: - `ucnv_countAvailable`, `ucnv_getAvailableName` and `ucnv_countStandards` take no guest pointers and return ICU's result directly. - `ucnv_countAliases`, `ucnv_getAlias` and `ucnv_getStandardName` read the status with a checked copy and return 0 or null without touching other arguments when it already holds a failure. Otherwise they check the status is writable, copy the alias, converter and standard names in through checked guest reads (null stays null), call ICU and write back a changed status. - A null status throws `std::invalid_argument`; unreadable names or status throw through `NotImplemented_nid_no_patch`. - Returned strings are ICU-owned process-lifetime storage, borrowed the same way `ucnv_getAliases` already returns them. The bundled ICU data package omits `cnvalias.icu`, so today these report zero converters, zero standards or `U_FILE_ACCESS_ERROR` instead of throwing. The new debt fragment records that and that the console prototypes are unverified. ### Tested Linux (Ubuntu 24.04, GCC 13.3). `guest_icu_converter_aliases` gains a `NameQueries` case: signature checks, parity with the pinned ICU for every function across in- and out-of-range indexes, null, empty, valid, fuzzy-matched, unknown and over-long names, several standards and five incoming status values, guest readability of returned strings, null status, unreadable status, a status that is already a failure, and unreadable name and standard pointers. The test passes in a Release build and in an ASan + UBSan build (`ANYPS5_ENABLE_ASAN=ON`, `-fsanitize=undefined`); `guest_icu_converter_available_names`, `guest_icu_converter_canonical_name` and `guest_icu_converter_helpers` also pass. Only libSceIcu changed, so the full emulator build was skipped. Not tested on a console. ### 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
PrivacyOnion commented 2026-11-20 12:58:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-20T12:58:21Z.

Review: APPROVED


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

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_icu_converter_aliases_tests built cleanly.
  • CTest (guest_icu_converter_aliases):
    1/1 Test #4029: guest_icu_converter_aliases ......   Passed    0.07 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceIcu/ConverterAliases.cpp, core/libs/prx/libSceIcu/LegacyExports.cpp, core/libs/prx/libSceIcu/include/LegacyExports.hpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified that ucnv_countAvailable_nid_postfix, ucnv_getAvailableName_nid_postfix, ucnv_countStandards_nid_postfix, ucnv_countAliases_nid_postfix, ucnv_getAlias_nid_postfix, and ucnv_getStandardName_nid_postfix match standard ICU C API signatures and return types.
    • Audited BeginStatus in ConverterAliases.cpp: null error throws std::invalid_argument, guest pointer reads/writes are validated via CopyIn and Writable, and incoming U_FAILURE returns early without mutating status or other parameters.
    • Audited string parameter reads in ConverterAliases.cpp: ReadAlias safely bounds reads to UCNV_MAX_CONVERTER_NAME_LENGTH using CopyIn and handles null pointers gracefully by passing nullptr to ICU.
    • Audited memory lifetime and ownership: returned const char* pointers are process-lifetime strings owned by ICU's static/internal alias tables and are directly readable in AnyPS5's unified address space model.
    • Verified AGENTS.md compliance: no unauthorized comments, debt fragment added under docs/dev/debt/changes/feat-icu-ucnv-name-queries.md, and comprehensive unit tests added in GuestIcuConverterAliases.cpp exercising both valid, boundary, and error conditions.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5993057981 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24274#pullrequestreview-5993057981). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-20T12:58:21Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `4e8bdbceb9`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_icu_converter_aliases_tests` built cleanly. - **CTest** (`guest_icu_converter_aliases`): ``` 1/1 Test #4029: guest_icu_converter_aliases ...... Passed 0.07 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceIcu/ConverterAliases.cpp`, `core/libs/prx/libSceIcu/LegacyExports.cpp`, `core/libs/prx/libSceIcu/include/LegacyExports.hpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Verified that ucnv_countAvailable_nid_postfix, ucnv_getAvailableName_nid_postfix, ucnv_countStandards_nid_postfix, ucnv_countAliases_nid_postfix, ucnv_getAlias_nid_postfix, and ucnv_getStandardName_nid_postfix match standard ICU C API signatures and return types. - Audited BeginStatus in ConverterAliases.cpp: null error throws std::invalid_argument, guest pointer reads/writes are validated via CopyIn and Writable, and incoming U_FAILURE returns early without mutating status or other parameters. - Audited string parameter reads in ConverterAliases.cpp: ReadAlias safely bounds reads to UCNV_MAX_CONVERTER_NAME_LENGTH using CopyIn and handles null pointers gracefully by passing nullptr to ICU. - Audited memory lifetime and ownership: returned const char* pointers are process-lifetime strings owned by ICU's static/internal alias tables and are directly readable in AnyPS5's unified address space model. - Verified AGENTS.md compliance: no unauthorized comments, debt fragment added under docs/dev/debt/changes/feat-icu-ucnv-name-queries.md, and comprehensive unit tests added in GuestIcuConverterAliases.cpp exercising both valid, boundary, and error conditions. Looks Good To Me
MarcZX10 commented 2026-11-20 13:35:39 +00:00 (Migrated from github.com)

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

Review: COMMENTED


Reviewed — no blocking findings

The reviewed change implements the six ICU converter name queries with checked guest access for status and name arguments; no concrete blocking defect was verified.

What I ran

Reviewed head 4e8bdbceb9bf8c5f0a3bc9aa28d7208ade4b9f6b from the prepared diff and pinned reader. No build or tests were run. The PR description reports Linux Release and ASan/UBSan test runs; those were not independently verified.

Files read: review/description.md, review/commits.md, review/manifest.json, review/diff.patch, core/libs/prx/libSceIcu/ConverterAliases.cpp, core/libs/prx/libSceIcu/include/LegacyExports.hpp (header lines 1–20), and core/libs/tests/GuestIcuConverterAliases.cpp.

Results

Check Result Note
Diff and changed implementation passed Inspected implementation and declarations
Tests not run PR-reported results not independently verified
Console ABI and behavior not run PR identifies this as unverified

Findings

Blocking

None verified in the inspected code.

Non-blocking

None.

Not verified

LegacyExports.cpp and docs/dev/debt/changes/feat-icu-ucnv-name-queries.md were listed in the manifest but not read; their full text was not available in the prepared artifact and they were not inspected through the reader. The changed header declarations were located through the diff and repository search, but the full header was not read. No tests, build, console behavior, or console ABI were independently verified. files.json was not available through the reader, so excluded-file details beyond the manifest were not checked.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5993509198 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24274#pullrequestreview-5993509198). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T13:35:39Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The reviewed change implements the six ICU converter name queries with checked guest access for status and name arguments; no concrete blocking defect was verified. ## What I ran Reviewed head `4e8bdbceb9bf8c5f0a3bc9aa28d7208ade4b9f6b` from the prepared diff and pinned reader. No build or tests were run. The PR description reports Linux Release and ASan/UBSan test runs; those were not independently verified. Files read: `review/description.md`, `review/commits.md`, `review/manifest.json`, `review/diff.patch`, `core/libs/prx/libSceIcu/ConverterAliases.cpp`, `core/libs/prx/libSceIcu/include/LegacyExports.hpp` (header lines 1–20), and `core/libs/tests/GuestIcuConverterAliases.cpp`. ## Results | Check | Result | Note | |---|---|---| | Diff and changed implementation | passed | Inspected implementation and declarations | | Tests | not run | PR-reported results not independently verified | | Console ABI and behavior | not run | PR identifies this as unverified | ## Findings ### Blocking None verified in the inspected code. ### Non-blocking None. ## Not verified `LegacyExports.cpp` and `docs/dev/debt/changes/feat-icu-ucnv-name-queries.md` were listed in the manifest but not read; their full text was not available in the prepared artifact and they were not inspected through the reader. The changed header declarations were located through the diff and repository search, but the full header was not read. No tests, build, console behavior, or console ABI were independently verified. `files.json` was not available through the reader, so excluded-file details beyond the manifest were not checked. ## 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!24274
No description provided.