fix(libSceCesCs): map the strict JIS X 0208 profiles' unsettled cells as the console does #10718

Merged
rooklz merged 1 commit from upstream-pr/10718 into main 2026-10-26 01:40:45 +00:00
rooklz commented 2026-10-24 19:09:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-10-24T19:09:46Z.


What

The strict JIS X 0208 profiles (sceCesUcsProfileInitSJis1997X0208, sceCesUcsProfileInitEucJpX0208, X0208Ss2 and X0208Ss2Ss3) threw on the cells whose console mapping was unknown: JIS cell 0x2140, U+FF3C, and in the Shift-JIS profile the bytes 0x5C and 0x7E and U+005C, U+007E, U+00A5 and U+203E. They now map them as a PS5 does.

I measured every profile on a PS5 with homebrew payloads that load the console's libSceCesCs.sprx and call sceCesMbcToUtf32 on every one- and two-byte sequence and sceCesUtf32ToMbc on every value from U+0000 to U+110001. On the console:

  • Cell 0x2140 is U+005C in the Shift-JIS profile and U+FF3C in the three EUC-JP profiles, both ways.
  • Shift-JIS bytes 0x5C and 0x7E are JIS X 0201 Roman: U+00A5 and U+203E, both ways. U+005C encodes as 0x815F; U+007E and U+FF3C are unassigned.
  • Cell 0x213D (0x815C / 0xA1BD) is U+2014, not CP932's U+2015, which is unassigned. This is the one cell that differs from the table besides the six JIS0208.TXT changes the profiles already had.
  • The EUC-JP profiles keep ASCII and also encode U+00A5 as 0xA1EF and U+203E as 0xA1B1, which decode as U+FFE5 and U+FFE3.

With the change, the JIS X 0208 two-byte decode of each strict profile hashes the same as the console's sweep (6879 assigned cells: EUC-JP 0xC1C98702, Shift-JIS 0x0CE46B27), and the encode and decode sweeps of these profiles match the console apart from topics outside this PR (the EUC single bytes and the error lengths, both separate).

Tested

  • guest_ces_japanese: the sweeps over all 94×94 cells of the strict EUC-JP and Shift-JIS profiles now count 6879 cells and check the hash computed from the console dump. The test also checks 0x2140 both ways in each profile, 0x815C/0xA1BD ↔ U+2014 with U+2015 unassigned, the Shift-JIS 0x5C/0x7E round trips and U+005C → 0x815F, the EUC-JP one-way U+00A5/U+203E forms, and an MBCS string with 0x5C; the throw checks are gone. The other guest_ces* tests still pass.
  • macOS (Apple clang 21, x86-64): all seven guest_ces* sources pass, built against this Export.cpp.
  • Hosted Linux runner, head 1a8c979023 (same tree as the verified 9cfa98bffe; verify run on my fork; Ubuntu 24.04, GCC, Release, lavapipe): every guest_ces* test passes. Its one failure, pr_overlap_encoding, fails the same way on main on that runner (the base side of the same run).
  • check_conventions.py passes. pr_overlap.py reports #10056, #10185 and #10186 on the same Export.cpp lines, the GuestCesJapanese.cpp checks and the debt entries; none changes the strict profiles. #10186 measured the CP932 and CP51932 encoders on a PS5 and agrees with this on the cells both touch (U+00A5 → 0xA1EF and U+203E → 0xA1B1 in EUC-JP).

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: #10722
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4998310589 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10718). Originally posted by [rooklz](https://github.com/rooklz) on 2026-10-24T19:09:46Z. --- ### What The strict JIS X 0208 profiles (`sceCesUcsProfileInitSJis1997X0208`, `sceCesUcsProfileInitEucJpX0208`, `X0208Ss2` and `X0208Ss2Ss3`) threw on the cells whose console mapping was unknown: JIS cell `0x2140`, U+FF3C, and in the Shift-JIS profile the bytes `0x5C` and `0x7E` and U+005C, U+007E, U+00A5 and U+203E. They now map them as a PS5 does. I measured every profile on a PS5 with homebrew payloads that load the console's `libSceCesCs.sprx` and call `sceCesMbcToUtf32` on every one- and two-byte sequence and `sceCesUtf32ToMbc` on every value from U+0000 to U+110001. On the console: - **Cell `0x2140`** is U+005C in the Shift-JIS profile and U+FF3C in the three EUC-JP profiles, both ways. - **Shift-JIS bytes `0x5C` and `0x7E`** are JIS X 0201 Roman: U+00A5 and U+203E, both ways. U+005C encodes as `0x815F`; U+007E and U+FF3C are unassigned. - **Cell `0x213D`** (`0x815C` / `0xA1BD`) is U+2014, not CP932's U+2015, which is unassigned. This is the one cell that differs from the table besides the six JIS0208.TXT changes the profiles already had. - **The EUC-JP profiles keep ASCII** and also encode U+00A5 as `0xA1EF` and U+203E as `0xA1B1`, which decode as U+FFE5 and U+FFE3. With the change, the JIS X 0208 two-byte decode of each strict profile hashes the same as the console's sweep (6879 assigned cells: EUC-JP `0xC1C98702`, Shift-JIS `0x0CE46B27`), and the encode and decode sweeps of these profiles match the console apart from topics outside this PR (the EUC single bytes and the error lengths, both separate). ### Tested - `guest_ces_japanese`: the sweeps over all 94×94 cells of the strict EUC-JP and Shift-JIS profiles now count 6879 cells and check the hash computed from the console dump. The test also checks `0x2140` both ways in each profile, `0x815C`/`0xA1BD` ↔ U+2014 with U+2015 unassigned, the Shift-JIS `0x5C`/`0x7E` round trips and U+005C → `0x815F`, the EUC-JP one-way U+00A5/U+203E forms, and an MBCS string with `0x5C`; the throw checks are gone. The other `guest_ces*` tests still pass. - macOS (Apple clang 21, x86-64): all seven `guest_ces*` sources pass, built against this `Export.cpp`. - Hosted Linux runner, head `1a8c979023` (same tree as the verified `9cfa98bffe`; [verify run on my fork](https://github.com/rooklz/AnyPS5/actions/runs/40124277403); Ubuntu 24.04, GCC, Release, lavapipe): every `guest_ces*` test passes. Its one failure, `pr_overlap_encoding`, fails the same way on `main` on that runner (the base side of the same run). - `check_conventions.py` passes. `pr_overlap.py` reports #10056, #10185 and #10186 on the same `Export.cpp` lines, the `GuestCesJapanese.cpp` checks and the debt entries; none changes the strict profiles. #10186 measured the CP932 and CP51932 encoders on a PS5 and agrees with this on the cells both touch (U+00A5 → `0xA1EF` and U+203E → `0xA1B1` in EUC-JP). ### 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: #10722 <!-- #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 19:22:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T19:22:32Z.

Review: APPROVED


Reviewed at head 9cfa98bffee932d23d00c0bd43f0ed2ca7e46443. The profile-specific handling is consistent across decoding and reverse-table encoding: strict Shift-JIS maps 0x2140 to U+005C, applies JIS X 0201 Roman for 0x5C/0x7E, and leaves the stated unassigned values unassigned; EUC-JP keeps ASCII behavior while applying its measured 0x2140 and one-way yen/overline fallbacks. The separate reverse tables avoid changing CP932/CP51932 behavior. The exhaustive console-derived digest assertions and explicit boundary/round-trip checks are useful coverage. git diff --check upstream/main...HEAD and python3 tools/check_conventions.py --base upstream/main pass locally. The PR is mergeable and hosted intake/conventions/labels are green; hosted product builds/tests are skipped by policy. I could not run the CES target locally during this session, so I am relying on the documented PS5 sweeps and the reported macOS build; the linked Linux run shows one pr_overlap_encoding failure on both base and change, which is reported as baseline-specific.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5639594993 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10718#pullrequestreview-5639594993). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T19:22:32Z. **Review:** APPROVED --- Reviewed at head `9cfa98bffee932d23d00c0bd43f0ed2ca7e46443`. The profile-specific handling is consistent across decoding and reverse-table encoding: strict Shift-JIS maps 0x2140 to U+005C, applies JIS X 0201 Roman for 0x5C/0x7E, and leaves the stated unassigned values unassigned; EUC-JP keeps ASCII behavior while applying its measured 0x2140 and one-way yen/overline fallbacks. The separate reverse tables avoid changing CP932/CP51932 behavior. The exhaustive console-derived digest assertions and explicit boundary/round-trip checks are useful coverage. `git diff --check upstream/main...HEAD` and `python3 tools/check_conventions.py --base upstream/main` pass locally. The PR is mergeable and hosted intake/conventions/labels are green; hosted product builds/tests are skipped by policy. I could not run the CES target locally during this session, so I am relying on the documented PS5 sweeps and the reported macOS build; the linked Linux run shows one `pr_overlap_encoding` failure on both base and change, which is reported as baseline-specific.
MarcZX10 commented 2026-10-24 20:20:51 +00:00 (Migrated from github.com)

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

Review: APPROVED


Reviewed the complete diff at 1a8c9790236975919c8a50504e01917aa7b23b90. The strict profile mapping now differentiates the PS5-measured Shift-JIS and EUC-JP behavior for cell 0x2140, Shift-JIS Roman bytes, EUC fallback encodings, and cell 0x213D; reverse tables use the matching strict profile. The PR reports full console sweeps over byte sequences and Unicode scalars, matching assigned-cell counts/digests, plus passing macOS and hosted Linux CES test suites. Conventions and labels passed; product Linux/Windows jobs were skipped under workflow policy.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5639804415 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10718#pullrequestreview-5639804415). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T20:20:51Z. **Review:** APPROVED --- Reviewed the complete diff at 1a8c9790236975919c8a50504e01917aa7b23b90. The strict profile mapping now differentiates the PS5-measured Shift-JIS and EUC-JP behavior for cell 0x2140, Shift-JIS Roman bytes, EUC fallback encodings, and cell 0x213D; reverse tables use the matching strict profile. The PR reports full console sweeps over byte sequences and Unicode scalars, matching assigned-cell counts/digests, plus passing macOS and hosted Linux CES test suites. Conventions and labels passed; product Linux/Windows jobs were skipped under workflow policy.
MarcZX10 commented 2026-10-25 02:56:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T02:56:46Z.

Review: DISMISSED


The updated mapping and exhaustive console-derived assertions look consistent, but the required overlap declaration is incomplete. #10722 lists this PR in its overlap report and changes the same CES decoder/encoder paths in Export.cpp. CONTRIBUTING.md requires the authors to agree on merge order and declare it with Depends on. Please coordinate with #10722 and update both checklists to name the agreed order; the current Depends on: none does not record it. I have not modified or rebased your branch. Hosted conventions, eligibility, labels and report checks pass; product build/test jobs are skipped. My earlier approvals apply only to the old head, not this updated head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5641250763 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10718#pullrequestreview-5641250763). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-25T02:56:46Z. **Review:** DISMISSED --- The updated mapping and exhaustive console-derived assertions look consistent, but the required overlap declaration is incomplete. #10722 lists this PR in its overlap report and changes the same CES decoder/encoder paths in Export.cpp. CONTRIBUTING.md requires the authors to agree on merge order and declare it with `Depends on`. Please coordinate with #10722 and update both checklists to name the agreed order; the current `Depends on: none` does not record it. I have not modified or rebased your branch. Hosted conventions, eligibility, labels and report checks pass; product build/test jobs are skipped. My earlier approvals apply only to the old head, not this updated head.
MarcZX10 commented 2026-10-25 04:25:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T04:25:24Z.

Review: APPROVED


Reviewed exact head b96b3434e077a503456683112a4c3a7f1d8082d4. The stack is recorded consistently: #10722 is the immediate parent and this commit applies the strict JIS X 0208 profile mapping on top. The profile-specific decode and reverse-encode paths agree for 0x2140, Shift-JIS Roman 0x5C/0x7E, the measured 0x213D mapping, and EUC-JP fallbacks; non-strict CP932/CP51932 behavior remains on its existing tables. The exhaustive digest and explicit regression assertions cover the changed cells and round trips. Local and pass. Hosted eligibility, labels and current conventions pass; product builds are skipped by workflow policy. I did not rerun the console sweeps or macOS/Linux CES test suite locally; those remain author-reported, and the linked Linux overlap failure is reported on base as well.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5641482645 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10718#pullrequestreview-5641482645). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-25T04:25:24Z. **Review:** APPROVED --- Reviewed exact head b96b3434e077a503456683112a4c3a7f1d8082d4. The stack is recorded consistently: #10722 is the immediate parent and this commit applies the strict JIS X 0208 profile mapping on top. The profile-specific decode and reverse-encode paths agree for 0x2140, Shift-JIS Roman 0x5C/0x7E, the measured 0x213D mapping, and EUC-JP fallbacks; non-strict CP932/CP51932 behavior remains on its existing tables. The exhaustive digest and explicit regression assertions cover the changed cells and round trips. Local and pass. Hosted eligibility, labels and current conventions pass; product builds are skipped by workflow policy. I did not rerun the console sweeps or macOS/Linux CES test suite locally; those remain author-reported, and the linked Linux overlap failure is reported on base as well.
MarcZX10 commented 2026-10-25 04:25:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T04:25:32Z.

Review: APPROVED


Reviewed exact head b96b3434e077a503456683112a4c3a7f1d8082d4. The stack is recorded consistently: #10722 is the immediate parent and this commit applies the strict JIS X 0208 profile mapping on top. The profile-specific decode and reverse-encode paths agree for 0x2140, Shift-JIS Roman 0x5C/0x7E, the measured 0x213D mapping, and EUC-JP fallbacks; non-strict CP932/CP51932 behavior remains on its existing tables. The exhaustive digest and explicit regression assertions cover the changed cells and round trips. Local and All conventions checks passed. pass. Hosted eligibility, labels and current conventions pass; product builds are skipped by workflow policy. I did not rerun the console sweeps or macOS/Linux CES test suite locally; those remain author-reported, and the linked Linux overlap failure is reported on base as well.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5641482920 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10718#pullrequestreview-5641482920). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-25T04:25:32Z. **Review:** APPROVED --- Reviewed exact head b96b3434e077a503456683112a4c3a7f1d8082d4. The stack is recorded consistently: #10722 is the immediate parent and this commit applies the strict JIS X 0208 profile mapping on top. The profile-specific decode and reverse-encode paths agree for 0x2140, Shift-JIS Roman 0x5C/0x7E, the measured 0x213D mapping, and EUC-JP fallbacks; non-strict CP932/CP51932 behavior remains on its existing tables. The exhaustive digest and explicit regression assertions cover the changed cells and round trips. Local and All conventions checks passed. pass. Hosted eligibility, labels and current conventions pass; product builds are skipped by workflow policy. I did not rerun the console sweeps or macOS/Linux CES test suite locally; those remain author-reported, and the linked Linux overlap failure is reported on base as well.
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!10718
No description provided.