feat(libSceCesCs): convert two-byte EUC-JP characters through the CP932 table #5686

Merged
ps54all merged 1 commit from upstream-pr/5686 into main 2026-10-14 14:41:57 +00:00
ps54all commented 2026-10-14 06:30:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ps54all on 2026-10-14T06:30:50Z.


Depends on #5515 (this branch carries its commit until it merges; the diff of this PR alone is the second commit, 50afd8ce0).

What

The EUC-JP profile from #5515 converts ASCII and half-width katakana and throws on every two-byte character. This adds the two-byte rows 0xA1-0xFE:

  • core/libs/prx/libSceCesCs/JisX0208.hpp holds a 94x94 table (7336 of 8836 cells assigned) from Microsoft code page 932, read through the standard JIS row/cell to Shift-JIS arithmetic and Python's cp932 codec. It includes NEC row 13 and the NEC-selected IBM rows 89-92 and maps the Microsoft variants (U+FF5E at 0xA1C1, U+2225, U+FF0D, U+FFE0-U+FFE2). Against Python's euc_jp codec, the only differences are those variants, row 13 and rows 89-92.
  • Decoding a pair reads the table; encoding a code point looks it up in a reverse table built once on first use, and a character with several cells (row 13 and the IBM rows repeat JIS X 0208 characters) encodes to the lowest cell.
  • A well-formed but unassigned cell returns UNASSIGNED_CODE, a trail byte outside 0xA1-0xFE returns INVALID_ENCODE, a cut pair returns SRC_BUFFER_END.
  • Three-byte JIS X 0212 (0x8F) characters still throw.
  • The debt entry in docs/dev/debt/libSceCesCs.md records that the console's CP51932 table equalling cp932 is assumed, that its error codes for these cases are not known, and what stays unimplemented. I also rewrote the sceCesMbcsUcsContextInit entry, which still said nothing is stored.

Tested

Windows 11, RTX 3080, WinLibs GCC 15.2.0 r7, Release, on main f74ec639c.

  • guest_ces and guest_ces_module (18 ces-related tests in total pass): hiragana and kanji convert UTF-8 to EUC-JP and back (こんにちは日本語 is A4B3 A4F3 A4CB A4C1 A4CF C6FC CBDC B8EC), UCS-2 in and out, a NEC row 13 character (U+2460 is ADA1), U+FF5E (A1C1), a character with several cells encoding to the lowest (U+2252 is A2E2), an unassigned cell, a bad trail byte, a cut pair, a code point with no cell (U+00A5), and a round trip over every one of the 7336 assigned cells. Without the table code the test aborts at the first two-byte conversion; with it both pass.
  • python tools/check_conventions.py --base origin/main and tools/check_test_registration.py pass.
  • Not run in a title: Metal Gear Solid 4 (PPSA18194) imports this conversion set, but I have not observed it converting a two-byte string, so the table is covered by the unit test only.

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
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source (table is generated data, derived from the Microsoft code page)
  • Generic behaviour, not specific to one title
  • Depends on: #5515
  • Unblocks: nothing verified (PPSA18194 imports this conversion set)
  • GPUs tested: n/a
  • AI-assisted: yes (Claude Code); the runs are on my machine.

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4853922026 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5686). Originally posted by [ps54all](https://github.com/ps54all) on 2026-10-14T06:30:50Z. --- Depends on #5515 (this branch carries its commit until it merges; the diff of this PR alone is the second commit, `50afd8ce0`). ### What The EUC-JP profile from #5515 converts ASCII and half-width katakana and throws on every two-byte character. This adds the two-byte rows `0xA1`-`0xFE`: - `core/libs/prx/libSceCesCs/JisX0208.hpp` holds a 94x94 table (7336 of 8836 cells assigned) from Microsoft code page 932, read through the standard JIS row/cell to Shift-JIS arithmetic and Python's `cp932` codec. It includes NEC row 13 and the NEC-selected IBM rows 89-92 and maps the Microsoft variants (U+FF5E at `0xA1C1`, U+2225, U+FF0D, U+FFE0-U+FFE2). Against Python's `euc_jp` codec, the only differences are those variants, row 13 and rows 89-92. - Decoding a pair reads the table; encoding a code point looks it up in a reverse table built once on first use, and a character with several cells (row 13 and the IBM rows repeat JIS X 0208 characters) encodes to the lowest cell. - A well-formed but unassigned cell returns `UNASSIGNED_CODE`, a trail byte outside `0xA1`-`0xFE` returns `INVALID_ENCODE`, a cut pair returns `SRC_BUFFER_END`. - Three-byte JIS X 0212 (`0x8F`) characters still throw. - The debt entry in `docs/dev/debt/libSceCesCs.md` records that the console's CP51932 table equalling cp932 is assumed, that its error codes for these cases are not known, and what stays unimplemented. I also rewrote the `sceCesMbcsUcsContextInit` entry, which still said nothing is stored. ### Tested Windows 11, RTX 3080, WinLibs GCC 15.2.0 r7, Release, on main `f74ec639c`. - `guest_ces` and `guest_ces_module` (18 ces-related tests in total pass): hiragana and kanji convert UTF-8 to EUC-JP and back (`こんにちは日本語` is `A4B3 A4F3 A4CB A4C1 A4CF C6FC CBDC B8EC`), UCS-2 in and out, a NEC row 13 character (U+2460 is `ADA1`), U+FF5E (`A1C1`), a character with several cells encoding to the lowest (U+2252 is `A2E2`), an unassigned cell, a bad trail byte, a cut pair, a code point with no cell (U+00A5), and a round trip over every one of the 7336 assigned cells. Without the table code the test aborts at the first two-byte conversion; with it both pass. - `python tools/check_conventions.py --base origin/main` and `tools/check_test_registration.py` pass. - Not run in a title: Metal Gear Solid 4 (PPSA18194) imports this conversion set, but I have not observed it converting a two-byte string, so the table is covered by the unit test only. ### 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 - [x] Unimplemented paths throw - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source (table is generated data, derived from the Microsoft code page) - [x] Generic behaviour, not specific to one title - [x] Depends on: #5515 - [x] Unblocks: nothing verified (PPSA18194 imports this conversion set) - [x] GPUs tested: n/a - [x] AI-assisted: yes (Claude Code); the runs are on my machine. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
adriadam10 commented 2026-10-14 14:19:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T14:19:29Z.


Checked the build, guest_ces/guest_ces_module (pass; guest_ces fails without the table code) and the buffer/limit handling of the two-byte path. I also regenerated the 94x94 table from Python's cp932 codec through the JIS-to-Shift-JIS arithmetic: all 8836 cells match (7336 assigned).

Added on your branch: rebased onto current main, dropping the #5515 commit that already landed (its content is on main with our edits), and resolved the docs/dev/debt/libSceCesCs.md conflict by keeping your new entry text. Merging once the full build is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6170528249 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5686#issuecomment-6170528249). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-14T14:19:29Z. --- Checked the build, `guest_ces`/`guest_ces_module` (pass; `guest_ces` fails without the table code) and the buffer/limit handling of the two-byte path. I also regenerated the 94x94 table from Python's `cp932` codec through the JIS-to-Shift-JIS arithmetic: all 8836 cells match (7336 assigned). Added on your branch: rebased onto current `main`, dropping the #5515 commit that already landed (its content is on `main` with our edits), and resolved the `docs/dev/debt/libSceCesCs.md` conflict by keeping your new entry text. Merging once the full build is green.
ps54all commented 2026-10-14 16:08:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ps54all on 2026-10-14T16:08:19Z.


Thanks @adriadam10, also for regenerating the 94x94 table independently and dropping the landed #5515 commit from the branch.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6172741978 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5686#issuecomment-6172741978). Originally posted by [ps54all](https://github.com/ps54all) on 2026-10-14T16:08:19Z. --- Thanks @adriadam10, also for regenerating the 94x94 table independently and dropping the landed #5515 commit from the branch. AI-assisted (Claude Code).
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!5686
No description provided.