feat(libSceCesCs): add the ISO 646 national variants and JIS X 0201 profiles #10430

Merged
rooklz merged 2 commits from upstream-pr/10430 into main 2026-10-28 18:26:51 +00:00
rooklz commented 2026-10-24 00:04:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-10-24T00:04:44Z.


What

Twelve single-byte profile getters that still threw now return profiles: sceCesRefersUcsProfileAscii, AsciiWithKatakana, Bs4730, GbT1988, GbT1988Tilde0x7e, JisX0201, JisX0201Katakana, JisX0201Roman, JisX0201RomanTilde0x7e, JisX0201Tilde0x7e, KsX1003 and KsX1003Tilde0x7e. They work with every existing single-byte scalar converter (sceCesSbcTo*, sceCes*ToSbc) and with the MBCS string and length functions through sceCesMbcsUcsContextInit, as the 27 profiles of #8923 do.

The tables are measured on a PS5. A homebrew payload that loads the console's libSceCesCs.sprx called sceCesSbcToUtf32 on every byte and sceCesUtf32ToSbc on every BMP scalar for these twelve profiles and the 30 already on main, and each of the twelve now hashes the same as the console's sweep (guest_ces_iso646 pins the hashes). On the console:

  • The 7-bit sets (ASCII, BS 4730, GB 1988-80 and its tilde variant, JIS X 0201 Roman and its tilde variant, JIS X 0201 Katakana, KS X 1003 and its tilde variant) answer CES_ERROR_INVALID_ENCODE for bytes 0x80-0xFF, not UNASSIGNED_CODE.
  • The changed positions: BS 4730 changes only 0x23 (£); 0x7E stays a tilde. GB 1988-80 puts ¥ at 0x24, JIS X 0201 Roman ¥ at 0x5C, KS X 1003 ₩ at 0x5C, and the base GB, JIS and KS sets put an overline at 0x7E, which the Tilde0x7e variants keep as ~. A reassigned ASCII character has no byte.
  • JIS X 0201 Katakana is a 7-bit set: 0x21-0x5F are U+FF61-U+FF9F and 0x60-0x7E are unassigned; the 8-bit profiles (JisX0201, JisX0201Tilde0x7e, AsciiWithKatakana) carry the katakana at 0xA1-0xDF.

SingleByte.hpp gains a two-entry low-half override list per table, an Unassigned marker (0xFFFF) for bytes a set does not define, and a 7-bit flag; sbcToUnicode reports an unassigned byte and the converters answer INVALID_ENCODE for a high byte of a 7-bit set.

Getter signatures follow the Orbital type database. The other single-byte forms (sceCesSbcToUtf8, ToUcs2, the string functions) share the tables and were not measured separately. The same sweep found the surrogate answer 0x805C0015 for every single-byte profile and the C1 holes of Cp1254 and Cp1258 on main; those are other changes (#10183 has the Cp125x ones).

Tested

  • Hosted Linux runner, head 209cbf758f (verify run on my fork; Ubuntu 24.04, GCC, Release, lavapipe): every guest_ces* test passes; its failures (agc_driver_sgpr_pattern_fill_keys) are main's on that runner. macOS (Apple clang 21, x86-64): every guest_ces* source passes against this Export.cpp, and a harness built from it matches the console dump for every input above.
  • guest_ces_iso646 (new, in both link variants): every byte of every new profile decodes to the expected character or answers CES_ERROR_UNASSIGNED_CODE through sceCesSbcToUtf8, sceCesSbcToUcs2 and sceCesSbcToUtf32, and encodes back through sceCesUtf8ToSbc, sceCesUcs2ToSbc and sceCesUtf32ToSbc; the reassigned positions refuse their ASCII character (sceCesUtf32ToSbc(0x5C, JisX0201Roman) is unassigned, 0x00A5 gives 0x5C); the 63 katakana round-trip to U+FF61-U+FF9F; the Tilde0x7e variants keep ~ and refuse U+203E; the fourteen profiles are distinct pointers; and an MBCS context on JIS X 0201 converts 5C B6 41 7E to ¥カA‾ and back and reports 0xE0 as unassigned.
  • guest_ces, guest_ces_unicode and guest_ces_mbc still pass, so the 27 earlier profiles and CP1252 are unchanged.
  • Linux x86-64 container (Ubuntu 24.04, GCC 13.3, Release, this head built from scratch with ccache): guest_ces_iso646, guest_ces_iso646_module, guest_ces, guest_ces_module, guest_ces_mbc and guest_ces_unicode pass, each binary run directly with its exit status checked.
  • Hosted runners (verify run on my fork, which fails a job on any ctest failure): the Windows full build (Server 2025, WinLibs GCC 15.2.0, Release) compiles everything and passes all sixteen guest_ces* tests, the two new ones included; the Linux full build (Ubuntu 24.04, GCC, Release, lavapipe) compiles everything and passes every guest_ces* test, its two failures being agc_driver_queued_index_read_order and agc_driver_sgpr_pattern_fill_keys, which main fails on that runner. An earlier run on 38445f98db, the same code without the Windows PATH entry for the new test, passed the Linux full build with every guest_ces* test green and agc_driver_sgpr_pattern_fill_keys as its only failure, which main fails on that runner; its Windows job could not load libSceCesCs.dll for the new test, which is why the entry is there.
  • check_conventions.py passes. pr_overlap.py reports #10056, #10183, #10185 and #10186 on the sbcToUnicode lines and #10214 and #9912 on the SingleByte.hpp table list; none implements these twelve profiles (#9912 and #10214 add CP1253/1255/1257 and CP858, #10056 eight sparse ISO 8859 and PC code pages). #10183 measured sceCesSbcToUtf8 and sceCesUtf8ToSbc on a PS5 and found undefined bytes answering 0x805C0020 in both directions, which is what the Unassigned entries here answer; it rewrites sbcToUnicode to the same bool shape, so whichever lands second resolves one hunk to the same code. #9175 adds a debt entry two lines above this one's.

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:4990809148 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10430). Originally posted by [rooklz](https://github.com/rooklz) on 2026-10-24T00:04:44Z. --- ### What Twelve single-byte profile getters that still threw now return profiles: `sceCesRefersUcsProfileAscii`, `AsciiWithKatakana`, `Bs4730`, `GbT1988`, `GbT1988Tilde0x7e`, `JisX0201`, `JisX0201Katakana`, `JisX0201Roman`, `JisX0201RomanTilde0x7e`, `JisX0201Tilde0x7e`, `KsX1003` and `KsX1003Tilde0x7e`. They work with every existing single-byte scalar converter (`sceCesSbcTo*`, `sceCes*ToSbc`) and with the MBCS string and length functions through `sceCesMbcsUcsContextInit`, as the 27 profiles of #8923 do. The tables are measured on a PS5. A homebrew payload that loads the console's `libSceCesCs.sprx` called `sceCesSbcToUtf32` on every byte and `sceCesUtf32ToSbc` on every BMP scalar for these twelve profiles and the 30 already on `main`, and each of the twelve now hashes the same as the console's sweep (`guest_ces_iso646` pins the hashes). On the console: - **The 7-bit sets** (ASCII, BS 4730, GB 1988-80 and its tilde variant, JIS X 0201 Roman and its tilde variant, JIS X 0201 Katakana, KS X 1003 and its tilde variant) answer `CES_ERROR_INVALID_ENCODE` for bytes `0x80`-`0xFF`, not `UNASSIGNED_CODE`. - **The changed positions**: BS 4730 changes only `0x23` (£); `0x7E` stays a tilde. GB 1988-80 puts ¥ at `0x24`, JIS X 0201 Roman ¥ at `0x5C`, KS X 1003 ₩ at `0x5C`, and the base GB, JIS and KS sets put an overline at `0x7E`, which the `Tilde0x7e` variants keep as `~`. A reassigned ASCII character has no byte. - **JIS X 0201 Katakana** is a 7-bit set: `0x21`-`0x5F` are U+FF61-U+FF9F and `0x60`-`0x7E` are unassigned; the 8-bit profiles (`JisX0201`, `JisX0201Tilde0x7e`, `AsciiWithKatakana`) carry the katakana at `0xA1`-`0xDF`. `SingleByte.hpp` gains a two-entry low-half override list per table, an `Unassigned` marker (`0xFFFF`) for bytes a set does not define, and a 7-bit flag; `sbcToUnicode` reports an unassigned byte and the converters answer `INVALID_ENCODE` for a high byte of a 7-bit set. Getter signatures follow the [Orbital type database](https://github.com/AlexAltea/orbital/blob/b321fcdbd700cc02da1cb1ad25412781d5ec73c6/tools/ida/db_types.json). The other single-byte forms (`sceCesSbcToUtf8`, `ToUcs2`, the string functions) share the tables and were not measured separately. The same sweep found the surrogate answer `0x805C0015` for every single-byte profile and the C1 holes of Cp1254 and Cp1258 on `main`; those are other changes (#10183 has the Cp125x ones). ### Tested - Hosted Linux runner, head `209cbf758f` ([verify run on my fork](https://github.com/rooklz/AnyPS5/actions/runs/40134510654); Ubuntu 24.04, GCC, Release, lavapipe): every `guest_ces*` test passes; its failures (agc_driver_sgpr_pattern_fill_keys) are `main`'s on that runner. macOS (Apple clang 21, x86-64): every `guest_ces*` source passes against this `Export.cpp`, and a harness built from it matches the console dump for every input above. - `guest_ces_iso646` (new, in both link variants): every byte of every new profile decodes to the expected character or answers `CES_ERROR_UNASSIGNED_CODE` through `sceCesSbcToUtf8`, `sceCesSbcToUcs2` and `sceCesSbcToUtf32`, and encodes back through `sceCesUtf8ToSbc`, `sceCesUcs2ToSbc` and `sceCesUtf32ToSbc`; the reassigned positions refuse their ASCII character (`sceCesUtf32ToSbc(0x5C, JisX0201Roman)` is unassigned, `0x00A5` gives `0x5C`); the 63 katakana round-trip to `U+FF61`-`U+FF9F`; the `Tilde0x7e` variants keep `~` and refuse `U+203E`; the fourteen profiles are distinct pointers; and an MBCS context on JIS X 0201 converts `5C B6 41 7E` to `¥カA‾` and back and reports `0xE0` as unassigned. - `guest_ces`, `guest_ces_unicode` and `guest_ces_mbc` still pass, so the 27 earlier profiles and CP1252 are unchanged. - Linux x86-64 container (Ubuntu 24.04, GCC 13.3, Release, this head built from scratch with ccache): `guest_ces_iso646`, `guest_ces_iso646_module`, `guest_ces`, `guest_ces_module`, `guest_ces_mbc` and `guest_ces_unicode` pass, each binary run directly with its exit status checked. - Hosted runners ([verify run on my fork](https://github.com/rooklz/AnyPS5/actions/runs/40038470184), which fails a job on any ctest failure): the Windows full build (Server 2025, WinLibs GCC 15.2.0, Release) compiles everything and passes all sixteen `guest_ces*` tests, the two new ones included; the Linux full build (Ubuntu 24.04, GCC, Release, lavapipe) compiles everything and passes every `guest_ces*` test, its two failures being `agc_driver_queued_index_read_order` and `agc_driver_sgpr_pattern_fill_keys`, which `main` fails on that runner. An earlier run on `38445f98db`, the same code without the Windows `PATH` entry for the new test, passed the Linux full build with every `guest_ces*` test green and `agc_driver_sgpr_pattern_fill_keys` as its only failure, which `main` fails on that runner; its Windows job could not load `libSceCesCs.dll` for the new test, which is why the entry is there. - `check_conventions.py` passes. `pr_overlap.py` reports #10056, #10183, #10185 and #10186 on the `sbcToUnicode` lines and #10214 and #9912 on the `SingleByte.hpp` table list; none implements these twelve profiles (#9912 and #10214 add CP1253/1255/1257 and CP858, #10056 eight sparse ISO 8859 and PC code pages). #10183 measured `sceCesSbcToUtf8` and `sceCesUtf8ToSbc` on a PS5 and found undefined bytes answering `0x805C0020` in both directions, which is what the `Unassigned` entries here answer; it rewrites `sbcToUnicode` to the same `bool` shape, so whichever lands second resolves one hunk to the same code. #9175 adds a debt entry two lines above this one's. ### 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: none <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
MarcZX10 commented 2026-10-24 00:13:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T00:13:08Z.

Review: APPROVED


Reviewed head cb3277e. The profile tables and converter paths consistently handle the low-byte overrides and unassigned high-byte sentinels, and the added tests exercise scalar and MBCS round trips across the profiles. I independently confirmed the JIS X 0201 Roman/katakana mappings against Unicode's JIS0201 mapping and ran C++20 syntax checks on Export.cpp and GuestCesIso646.cpp; both pass. The author reports the full focused Linux and Windows test runs in the PR description. The current hosted run passes conventions, eligibility, intake, labels and report; platform builds are skipped for these paths. I could not run the product tests in this environment because the SDL2 submodule and XRandR development dependency are unavailable. I found no blocking issue at this head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5635745035 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10430#pullrequestreview-5635745035). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T00:13:08Z. **Review:** APPROVED --- Reviewed head cb3277e. The profile tables and converter paths consistently handle the low-byte overrides and unassigned high-byte sentinels, and the added tests exercise scalar and MBCS round trips across the profiles. I independently confirmed the JIS X 0201 Roman/katakana mappings against Unicode's JIS0201 mapping and ran C++20 syntax checks on Export.cpp and GuestCesIso646.cpp; both pass. The author reports the full focused Linux and Windows test runs in the PR description. The current hosted run passes conventions, eligibility, intake, labels and report; platform builds are skipped for these paths. I could not run the product tests in this environment because the SDL2 submodule and XRandR development dependency are unavailable. I found no blocking issue at this 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!10430
No description provided.