fix(libSceCesCs): refuse the Cp1254 and Cp1258 holes and UTF-32 surrogates as a PS5 does #13898

Merged
zaryabzip merged 2 commits from upstream-pr/13898 into main 2026-11-01 07:46:38 +00:00
zaryabzip commented 2026-10-31 11:50:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by zaryabzip on 2026-10-31T11:50:53Z.


What

Replaces #13848, which the open-PR limit closed; same branch and head.

Two single-byte conversion answers now match what @rooklz measured on a PS5. That sweep converted every byte through sceCesSbcToUtf32 and every BMP scalar through sceCesUtf32ToSbc, for every single-byte profile:

PS5 main before
Cp1254 bytes 81 8D 8E 8F 90 9D 9E 0x805C0020 both ways C1 code points (U+0081…)
Cp1258 bytes 81 8A 8D 8E 8F 90 9A 9D 9E 0x805C0020 both ways C1 code points
sceCesUtf32ToSbc with a surrogate, every single-byte profile 0x805C0015 (ILLEGAL_CODE) 0x805C0014 (INVALID_ENCODE)

@BunnyFl's 13.42 run of the module gives the same Cp1254 and Cp1258 bytes. #10185 already made Cp1250 to 1252 answer this way. The same sweep found the ISO 8859, PC code page and KOI8 tables matching byte for byte, and Cp1256 with no holes.

  • Tables: the 16 bytes become the table's existing 0xFFFF (unassigned) marker. The reverse lookup then refuses U+0081 and the others too.
  • Surrogate: sceCesUtf32ToSbc answers 0x805C0015 after its existing profile and destination checks. sceCesUcs2ToSbc and the big- and little-endian UTF-32 forms share the helper but weren't measured, so they keep 0x805C0014, and GuestCesWide.cpp's Ucs2ToSbc(0xD800) row is unchanged.
  • Debt: the single-byte entry no longer says these holes map to C1. A new entry records the bytes, the surrogate answer and both sources, and says the MBCS context conversions and the other UTF-32 and UCS-2 forms weren't measured.

No function changes count.

Overlap: #10056 (approved, older) also rewrites the single-byte debt line, which this has to change because it says the holes map to C1. #10056 goes first and I'll rebase this onto it. Rechecked against main 5de1621ff1, which hasn't changed these files since the tested base: git merge-tree merges this cleanly with every other open pull request that merges with main, including #13573, which edits the debt lines just above.

Tests:

  • GuestCes.cpp's CheckSingleByteProfiles sweep now expects 0x805C0020 from sceCesSbcToUtf32 and sceCesUtf32ToSbc at those bytes, and the old round trip everywhere else.
  • GuestCesWide.cpp adds sceCesUtf32ToSbc(0xD800) with Cp1252 and (0xDFFF) with Cp1254.

Tested

Windows 11 (WinLibs MinGW-w64 GCC 15.2.0 UCRT r7, CMake 4.3.1, Ninja 1.13.2) and Ubuntu 24.04 on WSL2 (GCC 13.3.0, CMake 3.28.3, Ninja 1.11.1), both with 5f4b1c401e merged into main d93ebe62d9. The head 3c478fe2a4 differs from it only in where the surrogate note sits in the debt file.

  • No warnings in Export.cpp, SingleByte.hpp, GuestCes.cpp or GuestCesWide.cpp.
  • ctest -R guest_ces: 20 of 20 pass on both hosts, the module builds included; guest_ces passes 3 of 3 on --repeat until-fail:3.
  • Baseline: on that main with only the two test files, guest_ces and guest_ces_module abort at the first hole (Cp1254 byte 0x81 decodes to a C1 code point), and guest_ces_wide and guest_ces_wide_module at the first surrogate row (0x805C0014), on both hosts (Windows exit 0xc0000409, Linux SIGABRT).
  • tools/check_conventions.py passes.

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 (Claude Code)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5097241205 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13898). Originally posted by [zaryabzip](https://github.com/zaryabzip) on 2026-10-31T11:50:53Z. --- ### What Replaces #13848, which the open-PR limit closed; same branch and head. Two single-byte conversion answers now match what @rooklz [measured on a PS5](https://github.com/boykopovar/AnyPS5/pull/10183#issuecomment-6389941634). That sweep converted every byte through `sceCesSbcToUtf32` and every BMP scalar through `sceCesUtf32ToSbc`, for every single-byte profile: | | PS5 | `main` before | |---|---|---| | Cp1254 bytes `81 8D 8E 8F 90 9D 9E` | `0x805C0020` both ways | C1 code points (`U+0081`…) | | Cp1258 bytes `81 8A 8D 8E 8F 90 9A 9D 9E` | `0x805C0020` both ways | C1 code points | | `sceCesUtf32ToSbc` with a surrogate, every single-byte profile | `0x805C0015` (`ILLEGAL_CODE`) | `0x805C0014` (`INVALID_ENCODE`) | @BunnyFl's [13.42 run of the module](https://github.com/boykopovar/AnyPS5/pull/9912#issuecomment-6403897082) gives the same Cp1254 and Cp1258 bytes. #10185 already made Cp1250 to 1252 answer this way. The same sweep found the ISO 8859, PC code page and KOI8 tables matching byte for byte, and Cp1256 with no holes. - **Tables:** the 16 bytes become the table's existing `0xFFFF` (unassigned) marker. The reverse lookup then refuses `U+0081` and the others too. - **Surrogate:** `sceCesUtf32ToSbc` answers `0x805C0015` after its existing profile and destination checks. `sceCesUcs2ToSbc` and the big- and little-endian UTF-32 forms share the helper but weren't measured, so they keep `0x805C0014`, and `GuestCesWide.cpp`'s `Ucs2ToSbc(0xD800)` row is unchanged. - **Debt:** the single-byte entry no longer says these holes map to C1. A new entry records the bytes, the surrogate answer and both sources, and says the MBCS context conversions and the other UTF-32 and UCS-2 forms weren't measured. No function changes count. Overlap: #10056 (approved, older) also rewrites the single-byte debt line, which this has to change because it says the holes map to C1. #10056 goes first and I'll rebase this onto it. Rechecked against `main` 5de1621ff1, which hasn't changed these files since the tested base: `git merge-tree` merges this cleanly with every other open pull request that merges with `main`, including #13573, which edits the debt lines just above. Tests: - `GuestCes.cpp`'s `CheckSingleByteProfiles` sweep now expects `0x805C0020` from `sceCesSbcToUtf32` and `sceCesUtf32ToSbc` at those bytes, and the old round trip everywhere else. - `GuestCesWide.cpp` adds `sceCesUtf32ToSbc(0xD800)` with Cp1252 and `(0xDFFF)` with Cp1254. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Windows 11 (WinLibs MinGW-w64 GCC 15.2.0 UCRT r7, CMake 4.3.1, Ninja 1.13.2) and Ubuntu 24.04 on WSL2 (GCC 13.3.0, CMake 3.28.3, Ninja 1.11.1), both with 5f4b1c401e merged into `main` d93ebe62d9. The head 3c478fe2a4 differs from it only in where the surrogate note sits in the debt file. - No warnings in `Export.cpp`, `SingleByte.hpp`, `GuestCes.cpp` or `GuestCesWide.cpp`. - `ctest -R guest_ces`: 20 of 20 pass on both hosts, the module builds included; `guest_ces` passes 3 of 3 on `--repeat until-fail:3`. - Baseline: on that `main` with only the two test files, `guest_ces` and `guest_ces_module` abort at the first hole (Cp1254 byte 0x81 decodes to a C1 code point), and `guest_ces_wide` and `guest_ces_wide_module` at the first surrogate row (`0x805C0014`), on both hosts (Windows exit 0xc0000409, Linux SIGABRT). - `tools/check_conventions.py` passes. ### 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: <!-- #PR, or none --> none - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> n/a - [x] AI-assisted: <!-- yes / no --> yes (Claude Code)
MarcZX10 commented 2026-10-31 11:53:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T11:53:40Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

The implementation and reported tests look sound, but the PR body says #10056 must land first while its required Depends on checklist entry says none.

What I ran

Reviewed head 3c478fe2a4414ce30dccdf0cb3fb856dee0d1d69 against PR base 5de1621ff13712e8b3a6d70a2487b008d9ee80c3; the fresh preview against current main b8f0a6b2025605b78eb70646bda79f458a577c82 is clean. Environment: Debian Linux x86_64, Python 3.11.2. No local build or C++ tests were run.

python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 13898

Results

Check Result
Diff, conventions and current-main merge preview Passed.
Author-reported C++ tests ctest -R guest_ces: 20/20 on Windows and WSL2; baseline tests reportedly fail on the prior behavior. Not independently run here.
Hosted CI Conventions, eligibility, intake, labels and report passed; Windows and library-portability were still running, Linux was skipped.
Remaining precheck helpers ABI audit and test-quality helper files are absent from the isolated PR checkout; those helper invocations could not run.

Negative control

Assertion Change tested Outcome
The measured Cp1254/Cp1258 holes and UTF-32 surrogates return their specified errors Author reports running the changed tests on the PR base before applying the implementation Reported to fail at the old C1 mapping and old surrogate error; I did not independently rerun this control.

Findings

Blocking

The PR description says the open #10056 changes the same Single-byte profiles debt entry and must land first, but the template checklist says Depends on: none. The repository requires this dependency to be declared. Please change the checklist entry to Depends on: #10056. As you state in the PR, wait for #10056 to land before rebasing this debt-file overlap.

Non-blocking

None identified in this review.

Sources

Not verified

I did not build or run the C++ tests locally, test a PS5, or independently reproduce the reported Windows/WSL2 tests. The latest hosted Windows job was still in progress.

To get this to a good state

Declare #10056 in Depends on, let it land, then rebase this PR onto the resulting main. I’ll re-check the updated dependency and rerun the relevant checks on the new head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5722600075 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13898#pullrequestreview-5722600075). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-31T11:53:40Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested The implementation and reported tests look sound, but the PR body says #10056 must land first while its required `Depends on` checklist entry says `none`. ## What I ran Reviewed head `3c478fe2a4414ce30dccdf0cb3fb856dee0d1d69` against PR base `5de1621ff13712e8b3a6d70a2487b008d9ee80c3`; the fresh preview against current `main` `b8f0a6b2025605b78eb70646bda79f458a577c82` is clean. Environment: Debian Linux x86_64, Python 3.11.2. No local build or C++ tests were run. ```sh python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 13898 ``` ## Results | Check | Result | |---|---| | Diff, conventions and current-main merge preview | Passed. | | Author-reported C++ tests | `ctest -R guest_ces`: 20/20 on Windows and WSL2; baseline tests reportedly fail on the prior behavior. Not independently run here. | | Hosted CI | Conventions, eligibility, intake, labels and report passed; Windows and library-portability were still running, Linux was skipped. | | Remaining precheck helpers | ABI audit and test-quality helper files are absent from the isolated PR checkout; those helper invocations could not run. | ## Negative control | Assertion | Change tested | Outcome | |---|---|---| | The measured Cp1254/Cp1258 holes and UTF-32 surrogates return their specified errors | Author reports running the changed tests on the PR base before applying the implementation | Reported to fail at the old C1 mapping and old surrogate error; I did not independently rerun this control. | ## Findings ### Blocking The PR description says the open #10056 changes the same `Single-byte profiles` debt entry and must land first, but the template checklist says `Depends on: none`. The repository requires this dependency to be declared. Please change the checklist entry to `Depends on: #10056`. As you state in the PR, wait for #10056 to land before rebasing this debt-file overlap. ### Non-blocking None identified in this review. ## Sources - [This PR’s debt entry and implementation at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/3c478fe2a4414ce30dccdf0cb3fb856dee0d1d69/docs/dev/debt/libSceCesCs.md) - [Open #10056’s overlapping debt entry at its current head](https://github.com/boykopovar/AnyPS5/blob/75585974a83a4a1957b23c176ac50d2917c774ad/docs/dev/debt/libSceCesCs.md) - [Repository dependency checklist rule](https://github.com/boykopovar/AnyPS5/blob/5de1621ff13712e8b3a6d70a2487b008d9ee80c3/CONTRIBUTING.md) ## Not verified I did not build or run the C++ tests locally, test a PS5, or independently reproduce the reported Windows/WSL2 tests. The latest hosted Windows job was still in progress. ## To get this to a good state Declare `#10056` in `Depends on`, let it land, then rebase this PR onto the resulting `main`. I’ll re-check the updated dependency and rerun the relevant checks on the new head.
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!13898
No description provided.