feat(libSceIcu): implement UTF-32, Java UTF-8, comparison and configuration exports #12320

Merged
MarcZX10 merged 41 commits from upstream-pr/12320 into main 2026-11-06 00:41:08 +00:00
MarcZX10 commented 2026-10-28 09:21:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T09:21:51Z.


What

Implements 20 of the sceIcuUnknown_*_nid_no_patch stubs of libSceIcu that the PS5 3.20 export inventory (PS5-3.20_Libs) names, using the names that the NIDs hash to (checked with tools/nid_names.py) and the prototypes and behavior of ICU 78.1, unicode-org/icu@049e0d6a420629ac7db77256987d083a563287b5, the commit the escape decoder already cites. The code is written independently; ICU is only the reference for prototypes, error codes and edge cases. The stubs are replaced by named exports, so the remaining stub count drops from 112 to 92.

  • UTF-32 conversion (Utf32.cpp, ustrtrns.cpp): u_strFromUTF32, u_strFromUTF32WithSub, u_strToUTF32, u_strToUTF32WithSub.
  • Java modified UTF-8 (JavaUtf8.cpp, ustrtrns.cpp, utf_impl.cpp): u_strFromJavaModifiedUTF8WithSub, u_strToJavaModifiedUTF8.
  • Comparison and search (Compare.cpp, Search.cpp, ustring.cpp): u_strCompare, u_strstr, u_strrstr.
  • Character helpers (Character.cpp, uchar.cpp, unames.cpp): u_isISOControl, u_forDigit, u_getISOComment.
  • Configuration (Configuration.cpp, umutex.cpp, cmemory.cpp, putil.cpp, ucln_cmn.cpp): u_setMutexFunctions, u_setAtomicIncDecFunctions (both report U_UNSUPPORTED_ERROR as ICU does), u_setMemoryFunctions, u_setDataDirectory, u_getDataDirectory, u_setTimeZoneFilesDirectory, u_getTimeZoneFilesDirectory, u_cleanup. Stored state is guarded by mutexes.

Not implemented: u_strCompareIter stays a throwing stub because it needs the UCharIterator layout, which only the open iterator PR #11136 introduces. Nothing else from the Unicode property tables, converters or name data is touched.

None of the 20 names is implemented or removed by the 13 open libSceIcu PRs (#10962-#10967, #11088, #11115, #11118, #11122, #11132, #11136, #12294); this was checked by name against each diff. Those PRs also edit CMakeLists.txt, libSceIcu.hpp, Export.cpp and the debt file, so a textual conflict on those lines is possible whichever lands second. This PR keeps its own files and does not copy code from them.

Commits are cut per export group: implementation with its header and stub removal, then its tests, then its debt entry (39 commits). Only the final tree was built; the intermediate commits were not built one by one.

Availability caveat, recorded in the debt file: only 104 of the 661 inventory NIDs appear in the native libSceIcu export table, so whether each of these NIDs exists on current firmware is unproven. Firmware 13.42 is also reported (in #11132) to export no u_setMemoryFunctions. The functions stay as compatibility exports like the existing escape decoder. A null UErrorCode throws where ICU would dereference it, and a result longer than INT32_MAX throws. No console behavior of these exports was measured.

Tested

Linux x86-64 (host fails the CPU gate, so the archive build with the patched gate was used), GCC. Built libSceIcu and ran with run_tests.sh: guest_icu_utf32, guest_icu_java_utf8, guest_icu_compare, guest_icu_search, guest_icu_character, guest_icu_configuration, plus the existing guest_icu_unescape and guest_icu_version: 8/8 passed. tools/check_conventions.py --base upstream/main, test_public_headers.py --audit-only and git diff --check upstream/main are clean. The six new test programs also ran standalone under AddressSanitizer and UBSan with no findings.

The expected values in the tests were derived by reading the ICU source (UErrorCode values, preflight lengths, surrogate handling, the bytes swallowed by malformed UTF-8 sequences, the 0x2800 code point order adjustment). I checked by mutating the implementation that the UTF-32, comparison and search vectors fail when the pair or boundary logic is broken; I did not do that for every test. Not run: Windows, macOS, a console, or any title; the guest calling convention of the stored memory callbacks is never exercised because nothing calls them.

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:5048105290 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12320). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-28T09:21:51Z. --- ### What Implements 20 of the `sceIcuUnknown_*_nid_no_patch` stubs of libSceIcu that the PS5 3.20 export inventory ([PS5-3.20_Libs](https://github.com/DNNDHH/PS5-3.20_Libs/blob/b2a77c09cd71c01f34c790cfbe98c751a13262ad/libSceIcu.c)) names, using the names that the NIDs hash to (checked with `tools/nid_names.py`) and the prototypes and behavior of ICU 78.1, [unicode-org/icu@049e0d6a420629ac7db77256987d083a563287b5](https://github.com/unicode-org/icu/tree/049e0d6a420629ac7db77256987d083a563287b5), the commit the escape decoder already cites. The code is written independently; ICU is only the reference for prototypes, error codes and edge cases. The stubs are replaced by named exports, so the remaining stub count drops from 112 to 92. - UTF-32 conversion (`Utf32.cpp`, ustrtrns.cpp): `u_strFromUTF32`, `u_strFromUTF32WithSub`, `u_strToUTF32`, `u_strToUTF32WithSub`. - Java modified UTF-8 (`JavaUtf8.cpp`, ustrtrns.cpp, utf_impl.cpp): `u_strFromJavaModifiedUTF8WithSub`, `u_strToJavaModifiedUTF8`. - Comparison and search (`Compare.cpp`, `Search.cpp`, ustring.cpp): `u_strCompare`, `u_strstr`, `u_strrstr`. - Character helpers (`Character.cpp`, uchar.cpp, unames.cpp): `u_isISOControl`, `u_forDigit`, `u_getISOComment`. - Configuration (`Configuration.cpp`, umutex.cpp, cmemory.cpp, putil.cpp, ucln_cmn.cpp): `u_setMutexFunctions`, `u_setAtomicIncDecFunctions` (both report `U_UNSUPPORTED_ERROR` as ICU does), `u_setMemoryFunctions`, `u_setDataDirectory`, `u_getDataDirectory`, `u_setTimeZoneFilesDirectory`, `u_getTimeZoneFilesDirectory`, `u_cleanup`. Stored state is guarded by mutexes. Not implemented: `u_strCompareIter` stays a throwing stub because it needs the `UCharIterator` layout, which only the open iterator PR #11136 introduces. Nothing else from the Unicode property tables, converters or name data is touched. None of the 20 names is implemented or removed by the 13 open libSceIcu PRs (#10962-#10967, #11088, #11115, #11118, #11122, #11132, #11136, #12294); this was checked by name against each diff. Those PRs also edit `CMakeLists.txt`, `libSceIcu.hpp`, `Export.cpp` and the debt file, so a textual conflict on those lines is possible whichever lands second. This PR keeps its own files and does not copy code from them. Commits are cut per export group: implementation with its header and stub removal, then its tests, then its debt entry (39 commits). Only the final tree was built; the intermediate commits were not built one by one. Availability caveat, recorded in the debt file: only 104 of the 661 inventory NIDs appear in the native libSceIcu export table, so whether each of these NIDs exists on current firmware is unproven. Firmware 13.42 is also reported (in #11132) to export no `u_setMemoryFunctions`. The functions stay as compatibility exports like the existing escape decoder. A null `UErrorCode` throws where ICU would dereference it, and a result longer than `INT32_MAX` throws. No console behavior of these exports was measured. ### Tested Linux x86-64 (host fails the CPU gate, so the archive build with the patched gate was used), GCC. Built `libSceIcu` and ran with `run_tests.sh`: `guest_icu_utf32`, `guest_icu_java_utf8`, `guest_icu_compare`, `guest_icu_search`, `guest_icu_character`, `guest_icu_configuration`, plus the existing `guest_icu_unescape` and `guest_icu_version`: 8/8 passed. `tools/check_conventions.py --base upstream/main`, `test_public_headers.py --audit-only` and `git diff --check upstream/main` are clean. The six new test programs also ran standalone under AddressSanitizer and UBSan with no findings. The expected values in the tests were derived by reading the ICU source (UErrorCode values, preflight lengths, surrogate handling, the bytes swallowed by malformed UTF-8 sequences, the 0x2800 code point order adjustment). I checked by mutating the implementation that the UTF-32, comparison and search vectors fail when the pair or boundary logic is broken; I did not do that for every test. Not run: Windows, macOS, a console, or any title; the guest calling convention of the stored memory callbacks is never exercised because nothing calls them. ### 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](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
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!12320
No description provided.