feat(libSceCesCs): add the EUC-JIS-2004 and Shift_JIS-2004 profiles #10426

Merged
rooklz merged 3 commits from upstream-pr/10426 into main 2026-10-27 05:23:29 +00:00
rooklz commented 2026-10-24 00:02:35 +00:00 (Migrated from github.com)

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


What

sceCesUcsProfileInitEucJis2004 and sceCesUcsProfileInitSJis2004X0213 now initialise profiles for EUC-JIS-2004 and Shift_JIS-2004 instead of throwing. Both work with the MBCS string, length and scalar functions through sceCesMbcsUcsContextInit, sceCesMbcToUtf8 and the rest, as the EUC-JP and Shift-JIS profiles do, and cover both planes of JIS X 0213: plane 1 as the two-byte range (EUC A1-FE pairs, Shift-JIS leads 81-9F and E0-EF), plane 2 through SS3 (8F) in EUC and the leads F0-FC in Shift-JIS with the row arithmetic sceCesSJisCodeToJisX0213 already has, and the half-width katakana through SS2 or a single byte. The 303 characters outside the BMP come out as supplementary-plane scalars.

The tables are a new JisX0213.hpp generated from Project X0213's JIS X 0213:2004 mapping table (free to use, modify and distribute per its header), one uint32_t per cell of each plane. The 90 cells the table notes as having a fullwidth form use that form, which keeps A1 A4 meaning , (U+FF0C) as it does on the JIS X 0208 profiles; where JIS X 0213's own mapping differs from CP932 (wave dash, em dash, overline) the JIS X 0213 value is used. The 25 kana cells that only exist as a base character plus U+309A are unassigned in both directions, since the converters produce one scalar per character. What a console answers for any of this is not measured; the debt entry says so.

Measured on a PS5

I checked both profiles on a PS5 with homebrew payloads that load the console's libSceCesCs.sprx: sceCesMbcToUtf32 over every one-, two- and 0x8F-led three-byte sequence and sceCesUtf32ToMbc over every value from U+0000 to U+110001. That found three table differences, now fixed:

  • cells 1-17, 1-79 and 2-15 to 2-18 decode to U+FFE3, U+FFE5, U+FF07, U+FF02, U+FF0D and U+FF5E, not Project X0213's U+203E, U+00A5, ', ", - and ~; U+203E and U+00A5 still encode into 1-17 and 1-79;
  • EUC-JIS-2004's SS3 reads JIS X 0212 in the rows that plane 2 leaves empty, both ways (U+010A ↔ 8F AA AF), and plane 2 wins for a code point in both (U+4E02 → 8F A1 A2);
  • nothing else differs in the tables. The remaining differences are C1 bytes, 0x0E, surrogates and error lengths, which other PRs cover for every profile.

guest_ces_jis2004 checks each of these both ways in both profiles.

Tested

  • guest_ces_jis2004 (new, both link variants): on EUC-JIS-2004, A4 A2, AE A1 (a plane-1 row 14 character JIS X 0208 lacks), 8F A1 A1 (plane 2, U+20089), 8E B6 and A1 A4 round-trip with UTF-8 and the mixed string of them with UTF-8 and UTF-32; the か゚ cell is unassigned both ways; a truncated pair or SS3 sequence, a bad trail, a lone 80 and a bad SS2 byte give the expected errors; a Thai character is unassigned; the scalar sceCesMbcToUtf8 converts; sceCesEucJpToUcs2 refuses the profile; and the EUC-JP CP51932 profile answers unassigned for AE A1. On Shift_JIS-2004, 82 A0, 87 9F, F0 40 (plane 2), B6 and the mixed string round-trip; 82 F5 is unassigned; a truncated lead, FD and a bad trail give the expected errors; and the Shift-JIS CP932 profile answers unassigned for F0 40.

  • guest_ces, guest_ces_mbc, guest_ces_unicode, guest_ces_japanese, guest_ces_chinese, guest_ces_wide and guest_ces_dbcs still pass.

  • Linux x86-64 container (Ubuntu 24.04, GCC 13.3, Release, this head built from scratch with ccache): guest_ces_jis2004 and guest_ces_jis2004_module pass, and guest_ces, guest_ces_mbc, guest_ces_unicode, guest_ces_japanese, guest_ces_chinese, guest_ces_wide and guest_ces_dbcs 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.

  • check_conventions.py passes. pr_overlap.py reports #10056, #10185 and #10186 on the first lines of decodeMbcs and encodeMbcs, where this adds its one-line dispatch, #10214 on the debt file's neighbouring line, #9175 nearby in PendingExports.cpp, and #9912 as an uncompared sharer of the same files; none implements either export, and whichever lands second keeps both hunks.

  • Hosted Linux runner, head 00703acb9c (verify run on my fork; Ubuntu 24.04, GCC, Release, lavapipe): every guest_ces* test passes; its one failure, agc_driver_sgpr_pattern_fill_keys, is main's on that runner.

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:4990792212 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10426). Originally posted by [rooklz](https://github.com/rooklz) on 2026-10-24T00:02:35Z. --- ### What `sceCesUcsProfileInitEucJis2004` and `sceCesUcsProfileInitSJis2004X0213` now initialise profiles for EUC-JIS-2004 and Shift_JIS-2004 instead of throwing. Both work with the MBCS string, length and scalar functions through `sceCesMbcsUcsContextInit`, `sceCesMbcToUtf8` and the rest, as the EUC-JP and Shift-JIS profiles do, and cover both planes of JIS X 0213: plane 1 as the two-byte range (EUC `A1`-`FE` pairs, Shift-JIS leads `81`-`9F` and `E0`-`EF`), plane 2 through SS3 (`8F`) in EUC and the leads `F0`-`FC` in Shift-JIS with the row arithmetic `sceCesSJisCodeToJisX0213` already has, and the half-width katakana through SS2 or a single byte. The 303 characters outside the BMP come out as supplementary-plane scalars. The tables are a new `JisX0213.hpp` generated from [Project X0213's JIS X 0213:2004 mapping table](http://x0213.org/codetable/jisx0213-2004-std.txt) (free to use, modify and distribute per its header), one `uint32_t` per cell of each plane. The 90 cells the table notes as having a fullwidth form use that form, which keeps `A1 A4` meaning `,` (U+FF0C) as it does on the JIS X 0208 profiles; where JIS X 0213's own mapping differs from CP932 (wave dash, em dash, overline) the JIS X 0213 value is used. The 25 kana cells that only exist as a base character plus U+309A are unassigned in both directions, since the converters produce one scalar per character. What a console answers for any of this is not measured; the debt entry says so. ### Measured on a PS5 I checked both profiles on a PS5 with homebrew payloads that load the console's `libSceCesCs.sprx`: `sceCesMbcToUtf32` over every one-, two- and `0x8F`-led three-byte sequence and `sceCesUtf32ToMbc` over every value from U+0000 to U+110001. That found three table differences, now fixed: - cells 1-17, 1-79 and 2-15 to 2-18 decode to U+FFE3, U+FFE5, U+FF07, U+FF02, U+FF0D and U+FF5E, not Project X0213's U+203E, U+00A5, `'`, `"`, `-` and `~`; U+203E and U+00A5 still encode into 1-17 and 1-79; - EUC-JIS-2004's SS3 reads JIS X 0212 in the rows that plane 2 leaves empty, both ways (U+010A ↔ `8F AA AF`), and plane 2 wins for a code point in both (U+4E02 → `8F A1 A2`); - nothing else differs in the tables. The remaining differences are C1 bytes, `0x0E`, surrogates and error lengths, which other PRs cover for every profile. `guest_ces_jis2004` checks each of these both ways in both profiles. ### Tested - `guest_ces_jis2004` (new, both link variants): on EUC-JIS-2004, `A4 A2`, `AE A1` (a plane-1 row 14 character JIS X 0208 lacks), `8F A1 A1` (plane 2, U+20089), `8E B6` and `A1 A4` round-trip with UTF-8 and the mixed string of them with UTF-8 and UTF-32; the か゚ cell is unassigned both ways; a truncated pair or SS3 sequence, a bad trail, a lone `80` and a bad SS2 byte give the expected errors; a Thai character is unassigned; the scalar `sceCesMbcToUtf8` converts; `sceCesEucJpToUcs2` refuses the profile; and the EUC-JP CP51932 profile answers unassigned for `AE A1`. On Shift_JIS-2004, `82 A0`, `87 9F`, `F0 40` (plane 2), `B6` and the mixed string round-trip; `82 F5` is unassigned; a truncated lead, `FD` and a bad trail give the expected errors; and the Shift-JIS CP932 profile answers unassigned for `F0 40`. - `guest_ces`, `guest_ces_mbc`, `guest_ces_unicode`, `guest_ces_japanese`, `guest_ces_chinese`, `guest_ces_wide` and `guest_ces_dbcs` still pass. - Linux x86-64 container (Ubuntu 24.04, GCC 13.3, Release, this head built from scratch with ccache): `guest_ces_jis2004` and `guest_ces_jis2004_module` pass, and `guest_ces`, `guest_ces_mbc`, `guest_ces_unicode`, `guest_ces_japanese`, `guest_ces_chinese`, `guest_ces_wide` and `guest_ces_dbcs` pass, each binary run directly with its exit status checked. - Hosted runners ([verify run on my fork](https://github.com/rooklz/AnyPS5/actions/runs/40038492539), 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. - `check_conventions.py` passes. `pr_overlap.py` reports #10056, #10185 and #10186 on the first lines of `decodeMbcs` and `encodeMbcs`, where this adds its one-line dispatch, #10214 on the debt file's neighbouring line, #9175 nearby in `PendingExports.cpp`, and #9912 as an uncompared sharer of the same files; none implements either export, and whichever lands second keeps both hunks. - Hosted Linux runner, head `00703acb9c` ([verify run on my fork](https://github.com/rooklz/AnyPS5/actions/runs/40126554994); Ubuntu 24.04, GCC, Release, lavapipe): every `guest_ces*` test passes; its one failure, `agc_driver_sgpr_pattern_fill_keys`, is `main`'s on that runner. ### 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 22:02:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T22:02:20Z.

Review: APPROVED


Reviewed exact head 00703acb9c97e8f02d434ec6cbe9bcec9d56bd0c.

The two profile initializers route into the existing MBCS conversion paths, and the generated plane tables preserve the documented one-scalar-per-cell policy for decomposed kana. The PR includes direct PS5 round-trip observations across the input ranges, with the discovered compatibility-cell and EUC plane-fallback differences reflected in the current table; the new focused tests pin those cases and invalid/truncated sequences. The table source's stated reuse terms were checked in the earlier review work, and the PR's attribution/license provenance is present.

Current-main merge-tree is clean; the 20 newer main commits do not modify the CES files touched here. Current-main conventions and diff-check pass. The PR's latest Linux run is reported on this exact head; the earlier Windows full build/test run is author-reported, and upstream product jobs are skipped by the workflow gate. I did not run the CES binaries locally.

No blocking findings on this head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5640200654 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10426#pullrequestreview-5640200654). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T22:02:20Z. **Review:** APPROVED --- Reviewed exact head `00703acb9c97e8f02d434ec6cbe9bcec9d56bd0c`. The two profile initializers route into the existing MBCS conversion paths, and the generated plane tables preserve the documented one-scalar-per-cell policy for decomposed kana. The PR includes direct PS5 round-trip observations across the input ranges, with the discovered compatibility-cell and EUC plane-fallback differences reflected in the current table; the new focused tests pin those cases and invalid/truncated sequences. The table source's stated reuse terms were checked in the earlier review work, and the PR's attribution/license provenance is present. Current-main merge-tree is clean; the 20 newer main commits do not modify the CES files touched here. Current-main conventions and diff-check pass. The PR's latest Linux run is reported on this exact head; the earlier Windows full build/test run is author-reported, and upstream product jobs are skipped by the workflow gate. I did not run the CES binaries locally. No blocking findings on 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!10426
No description provided.