feat(libSceCesCs): implement Unicode scalar conversions #7848

Merged
SibteProf merged 1 commit from upstream-pr/7848 into main 2026-10-20 02:36:34 +00:00
SibteProf commented 2026-10-19 10:53:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by SibteProf on 2026-10-19T10:53:00Z.


What

Implement 15 CES scalar conversion functions with real encoding behavior:

  • Add the 14 aerolib-listed UCS-2/UTF-8, UTF-8/UTF-16 and UTF-8/UTF-32 functions, including their explicit big-endian and little-endian forms. Signatures follow the Orbital type database. Encoding follows Unicode section 3.9.
  • Implement the existing throwing sceCesEucJpToUtf8 export using the existing CP51932 profile, JIS X 0208 and JIS X 0212 tables.
  • Convert exactly one scalar per call, including U+0000. Handle surrogate pairs and reject malformed UTF-8, isolated UTF-16 surrogates and out-of-range UTF-32. Check output capacity before writing, leave destinations and length outputs unchanged on failure, and append no terminator.
  • Build the same implementations into libSceCesCs and libSceCesCs-module through their shared source builder. Korean and Big5 conversions retain their throwing stubs.

The progress scanner on base ebf054c67 changes from 3889/4700 (82.74%) to 3904/4714 (82.82%): 14 previously undeclared functions implemented and one existing pending function completed. These counts describe implementations, not console verification or playable titles.

Console error precedence, optional length pointers, length units and the existing Japanese profile/table assumptions remain unverified and are recorded in docs/dev/debt/libSceCesCs.md. This PR makes no title-unblocking claim.

Tested

Windows 11, supported WinLibs MinGW-w64 GCC 15.2.0, Release, BUILD_TESTING=ON:

  • guest_ces, guest_ces_module, guest_ces_unicode and guest_ces_unicode_module: 4/4 passed. The new tests take about 0.15 seconds each locally.
  • Each new Unicode test exercises all 1,112,064 Unicode scalar values through all 14 Unicode exports. Aggregated UTF-8 and UTF-16LE bytes match reference FNV-1a hashes generated independently with Python's codecs (957cc0987e6013e5 and 6a25a430597ec325). Explicit byte-order fixtures, null pointers, short buffers, truncated and malformed input, surrogate failures and unchanged failure outputs are also checked.
  • Every 13,403 assigned JIS table cell, all unassigned cells, ASCII and half-width katakana are checked for the Japanese converter, including short output buffers. Temporarily restoring origin/main's Export.cpp makes the new behavioral test fail on its throwing Japanese converter; restoring this implementation passes.
  • New C++ sources pass -Wall -Wextra -Wconversion -Werror -fsyntax-only.
  • All production libraries and the converter built successfully in the full Windows configuration: cmake --build build --target libs relinker guest_ces_tests guest_ces_module_tests guest_ces_unicode_tests guest_ces_unicode_module_tests patched_libraries_tests --parallel 6.
  • Final CTest selection: 7/7 passed (guest_ces*, patched_libraries, progress_report, test_registration). The complete repository test suite was not run.
  • Conventions, test registration and whitespace checks pass.
  • tools/pr_overlap.py finds no duplicate exports or confirmed conflicts. It flags an uncomparable shared CMake file with #6044, whose broader branch conflicts with main. Manually reviewed that diff and verified a clean three-way merge of the shared CES CMake file after placing new test registration in a separate block. It changes existing test source paths and labels and implements none of these functions. No dependency is required.

No console, title, Linux or macOS runtime comparison was run.

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 (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a (no GPU changes)
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4919800610 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7848). Originally posted by [SibteProf](https://github.com/SibteProf) on 2026-10-19T10:53:00Z. --- ### What Implement 15 CES scalar conversion functions with real encoding behavior: - Add the 14 aerolib-listed UCS-2/UTF-8, UTF-8/UTF-16 and UTF-8/UTF-32 functions, including their explicit big-endian and little-endian forms. Signatures follow the [Orbital type database](https://github.com/AlexAltea/orbital/blob/b321fcdbd700cc02da1cb1ad25412781d5ec73c6/tools/ida/db_types.json). Encoding follows [Unicode section 3.9](https://www.unicode.org/versions/Unicode17.0.0/core-spec/chapter-3/). - Implement the existing throwing `sceCesEucJpToUtf8` export using the existing CP51932 profile, JIS X 0208 and JIS X 0212 tables. - Convert exactly one scalar per call, including U+0000. Handle surrogate pairs and reject malformed UTF-8, isolated UTF-16 surrogates and out-of-range UTF-32. Check output capacity before writing, leave destinations and length outputs unchanged on failure, and append no terminator. - Build the same implementations into `libSceCesCs` and `libSceCesCs-module` through their shared source builder. Korean and Big5 conversions retain their throwing stubs. The progress scanner on base `ebf054c67` changes from **3889/4700 (82.74%)** to **3904/4714 (82.82%)**: 14 previously undeclared functions implemented and one existing pending function completed. These counts describe implementations, not console verification or playable titles. Console error precedence, optional length pointers, length units and the existing Japanese profile/table assumptions remain unverified and are recorded in `docs/dev/debt/libSceCesCs.md`. This PR makes no title-unblocking claim. ### Tested Windows 11, supported WinLibs MinGW-w64 GCC 15.2.0, Release, `BUILD_TESTING=ON`: - `guest_ces`, `guest_ces_module`, `guest_ces_unicode` and `guest_ces_unicode_module`: **4/4 passed**. The new tests take about 0.15 seconds each locally. - Each new Unicode test exercises all **1,112,064 Unicode scalar values** through all 14 Unicode exports. Aggregated UTF-8 and UTF-16LE bytes match reference FNV-1a hashes generated independently with Python's codecs (`957cc0987e6013e5` and `6a25a430597ec325`). Explicit byte-order fixtures, null pointers, short buffers, truncated and malformed input, surrogate failures and unchanged failure outputs are also checked. - Every **13,403 assigned JIS table cell**, all unassigned cells, ASCII and half-width katakana are checked for the Japanese converter, including short output buffers. Temporarily restoring `origin/main`'s `Export.cpp` makes the new behavioral test fail on its throwing Japanese converter; restoring this implementation passes. - New C++ sources pass `-Wall -Wextra -Wconversion -Werror -fsyntax-only`. - All production libraries and the converter built successfully in the full Windows configuration: `cmake --build build --target libs relinker guest_ces_tests guest_ces_module_tests guest_ces_unicode_tests guest_ces_unicode_module_tests patched_libraries_tests --parallel 6`. - Final CTest selection: **7/7 passed** (`guest_ces*`, `patched_libraries`, `progress_report`, `test_registration`). The complete repository test suite was not run. - Conventions, test registration and whitespace checks pass. - `tools/pr_overlap.py` finds no duplicate exports or confirmed conflicts. It flags an uncomparable shared CMake file with #6044, whose broader branch conflicts with main. Manually reviewed that diff and verified a clean three-way merge of the shared CES CMake file after placing new test registration in a separate block. It changes existing test source paths and labels and implements none of these functions. No dependency is required. No console, title, Linux or macOS runtime comparison was run. ### 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 (none added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a (no GPU changes) - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-19 10:53:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-19T10:53:48Z.


Progress report (7f6ef06 → f9d6f3e)

📈 System libraries: 82.58% (+0.07%, +15 implemented functions)

✅ 15 implemented
Library Name
libSceCesCs sceCesEucJpToUtf8
libSceCesCs sceCesUcs2ToUtf8
libSceCesCs sceCesUtf16ToUtf8
libSceCesCs sceCesUtf16beToUtf8
libSceCesCs sceCesUtf16leToUtf8
libSceCesCs sceCesUtf32ToUtf8
libSceCesCs sceCesUtf32beToUtf8
libSceCesCs sceCesUtf32leToUtf8
libSceCesCs sceCesUtf8ToUcs2
libSceCesCs sceCesUtf8ToUtf16
libSceCesCs sceCesUtf8ToUtf16be
libSceCesCs sceCesUtf8ToUtf16le
libSceCesCs sceCesUtf8ToUtf32
libSceCesCs sceCesUtf8ToUtf32be
libSceCesCs sceCesUtf8ToUtf32le
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6265544061 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7848#issuecomment-6265544061). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-19T10:53:48Z. --- <!-- progress-report --> ### Progress report (7f6ef06 → f9d6f3e) 📈 **System libraries**: 82.58% (+0.07%, +15 implemented functions) <details> <summary>✅ 15 implemented</summary> | Library | Name | | - | - | | libSceCesCs | `sceCesEucJpToUtf8` | | libSceCesCs | `sceCesUcs2ToUtf8` | | libSceCesCs | `sceCesUtf16ToUtf8` | | libSceCesCs | `sceCesUtf16beToUtf8` | | libSceCesCs | `sceCesUtf16leToUtf8` | | libSceCesCs | `sceCesUtf32ToUtf8` | | libSceCesCs | `sceCesUtf32beToUtf8` | | libSceCesCs | `sceCesUtf32leToUtf8` | | libSceCesCs | `sceCesUtf8ToUcs2` | | libSceCesCs | `sceCesUtf8ToUtf16` | | libSceCesCs | `sceCesUtf8ToUtf16be` | | libSceCesCs | `sceCesUtf8ToUtf16le` | | libSceCesCs | `sceCesUtf8ToUtf32` | | libSceCesCs | `sceCesUtf8ToUtf32be` | | libSceCesCs | `sceCesUtf8ToUtf32le` | </details>
github-actions[bot] commented 2026-10-19 11:04:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-19T11:04:56Z.


Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 6044 core/libs/prx/libSceCesCs/CMakeLists.txt
PR 7884 core/libs/prx/libSceCesCs/CMakeLists.txt
core/libs/prx/libSceCesCs/Export.cpp
docs/dev/debt/libSceCesCs.md
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6265731590 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7848#issuecomment-6265731590). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-19T11:04:56Z. --- <!-- pr-overlap --> Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/prx/libSceCesCs/CMakeLists.txt` | | [PR 7884](https://www.github.com/boykopovar/AnyPS5/pull/7884) | `core/libs/prx/libSceCesCs/CMakeLists.txt`<br>`core/libs/prx/libSceCesCs/Export.cpp`<br>`docs/dev/debt/libSceCesCs.md` |
fogydes commented 2026-10-19 12:10:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fogydes on 2026-10-19T12:10:31Z.

Review: APPROVED


Reviewed the diff and test methodology:

  • Clean extraction of common build logic into CesLibrary.cmake serving both libSceCesCs and libSceCesCs-module shared targets.
  • Implements the 15 Unicode scalar conversions in Unicode.cpp (sceCes*ToUtf8, sceCesUtf8To*) handling UTF-8, UTF-16BE/LE, UTF-32BE/LE, and UCS-2 surrogate and byte-order conversions without non-standard extensions.
  • Comprehensive regression coverage in GuestCesUnicode.cpp testing all 1,112,064 Unicode scalar values against independent FNV-1a hashes, alongside truncation and buffer boundary assertions.
  • Technical debt in docs/dev/debt/libSceCesCs.md thoroughly updated under ### Functional and ### Unknown function info.
  • Zero comments added in production code; Conventional Commits title; all checklist items verified.

Ready to merge.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5571326539 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7848#pullrequestreview-5571326539). Originally posted by [fogydes](https://github.com/fogydes) on 2026-10-19T12:10:31Z. **Review:** APPROVED --- Reviewed the diff and test methodology: - Clean extraction of common build logic into `CesLibrary.cmake` serving both `libSceCesCs` and `libSceCesCs-module` shared targets. - Implements the 15 Unicode scalar conversions in `Unicode.cpp` (`sceCes*ToUtf8`, `sceCesUtf8To*`) handling UTF-8, UTF-16BE/LE, UTF-32BE/LE, and UCS-2 surrogate and byte-order conversions without non-standard extensions. - Comprehensive regression coverage in `GuestCesUnicode.cpp` testing all 1,112,064 Unicode scalar values against independent FNV-1a hashes, alongside truncation and buffer boundary assertions. - Technical debt in `docs/dev/debt/libSceCesCs.md` thoroughly updated under `### Functional` and `### Unknown function info`. - Zero comments added in production code; Conventional Commits title; all checklist items verified. Ready to merge. AI-assisted: yes
adriadam10 commented 2026-10-20 02:42:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-20T02:42:26Z.


Checked the UTF-8/16/32/UCS-2 scalar conversions (strict UTF-8, surrogate pairs, capacity check before write, outputs untouched on failure), the EUC-JP converter against the existing decoder, ctest registration (both variants) and the debt entries; merged.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6282093464 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7848#issuecomment-6282093464). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-20T02:42:26Z. --- Checked the UTF-8/16/32/UCS-2 scalar conversions (strict UTF-8, surrogate pairs, capacity check before write, outputs untouched on failure), the EUC-JP converter against the existing decoder, ctest registration (both variants) and the debt entries; merged.
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!7848
No description provided.