feat(libSceCesCs): implement generic MBCS character, Shift-JIS code and JIS X 0213 helpers #8993

Merged
simonbronk merged 6 commits from upstream-pr/8993 into main 2026-10-23 12:44:41 +00:00
simonbronk commented 2026-10-21 08:57:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by simonbronk on 2026-10-21T08:57:58Z.


What

Implements 13 libSceCesCs exports on top of the MBCS profiles of #8967, #8972 and #8976 (this branch carries their commits; the new commit is dc819fc6b):

  • sceCesMbcToUcs2, sceCesMbcToUtf8, sceCesMbcToUtf16/be/le, sceCesMbcToUtf32/be/le: convert one character with any profile the MBCS context accepts (Shift-JIS CP932, EUC-JP CP51932, GBK CP936, EUC-CN and the Cp1250/1251/1252 single-byte profiles), through the same helpers as the per-encoding scalar forms.
  • sceCesSJisGetCode, sceCesSJisPutCode: read and write one raw Shift-JIS code (one byte for ASCII and 0xA1-0xDF, two bytes for a valid lead/trail pair), without checking that the cell is assigned.
  • sceCesSJisCodeToJisX0213, sceCesJisX0213ToSJisCode: Shift_JIS-2004 arithmetic of JIS X 0213 annex 1; plane 1 as JIS X 0208, plane 2 rows 1, 3-5, 8, 12-15 and 78-94 on leads 0xF0-0xFC.
  • sceCesMbcsUcsContextInitCopy: copies the profile pointer stored by sceCesMbcsUcsContextInit.

Signatures follow the Orbital type database. Errors and their precedence follow the existing converters and are recorded as unverified in docs/dev/debt/libSceCesCs.md. sceCesMbcsUcsSetMbcsReplacementCharCode/UCode stay throwing: the context does not model a replacement character and its behaviour is unknown. Pending libSceCesCs exports: 161 → 148.

Tested

macOS (Apple clang, C++20): compiled libSceCesCs sources with the new core/libs/tests/GuestCesMbc.cpp (registered as guest_ces_mbc and guest_ces_mbc_module) and ran it, plus the existing GuestCes, GuestCesUnicode, GuestCesJapanese, GuestCesWide and GuestCesChinese: all pass. The full CMake/ctest build was not run (it does not build on macOS). tools/check_conventions.py --base origin/main passes. Not tested on Linux, Windows or a title.

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: #8976
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4949020051 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8993). Originally posted by [simonbronk](https://github.com/simonbronk) on 2026-10-21T08:57:58Z. --- ### What Implements 13 libSceCesCs exports on top of the MBCS profiles of #8967, #8972 and #8976 (this branch carries their commits; the new commit is dc819fc6b): - `sceCesMbcToUcs2`, `sceCesMbcToUtf8`, `sceCesMbcToUtf16`/`be`/`le`, `sceCesMbcToUtf32`/`be`/`le`: convert one character with any profile the MBCS context accepts (Shift-JIS CP932, EUC-JP CP51932, GBK CP936, EUC-CN and the Cp1250/1251/1252 single-byte profiles), through the same helpers as the per-encoding scalar forms. - `sceCesSJisGetCode`, `sceCesSJisPutCode`: read and write one raw Shift-JIS code (one byte for ASCII and `0xA1`-`0xDF`, two bytes for a valid lead/trail pair), without checking that the cell is assigned. - `sceCesSJisCodeToJisX0213`, `sceCesJisX0213ToSJisCode`: Shift_JIS-2004 arithmetic of JIS X 0213 annex 1; plane 1 as JIS X 0208, plane 2 rows 1, 3-5, 8, 12-15 and 78-94 on leads `0xF0`-`0xFC`. - `sceCesMbcsUcsContextInitCopy`: copies the profile pointer stored by `sceCesMbcsUcsContextInit`. Signatures follow the [Orbital type database](https://github.com/AlexAltea/orbital/blob/b321fcdbd700cc02da1cb1ad25412781d5ec73c6/tools/ida/db_types.json). Errors and their precedence follow the existing converters and are recorded as unverified in `docs/dev/debt/libSceCesCs.md`. `sceCesMbcsUcsSetMbcsReplacementCharCode`/`UCode` stay throwing: the context does not model a replacement character and its behaviour is unknown. Pending libSceCesCs exports: 161 → 148. ### Tested macOS (Apple clang, C++20): compiled `libSceCesCs` sources with the new `core/libs/tests/GuestCesMbc.cpp` (registered as `guest_ces_mbc` and `guest_ces_mbc_module`) and ran it, plus the existing `GuestCes`, `GuestCesUnicode`, `GuestCesJapanese`, `GuestCesWide` and `GuestCesChinese`: all pass. The full CMake/ctest build was not run (it does not build on macOS). `tools/check_conventions.py --base origin/main` passes. Not tested on Linux, Windows or a title. ### 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: #8976 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
rooklz commented 2026-10-21 13:08:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-10-21T13:08:24Z.


@simonbronk are you planning to keep going with libSceCesCs after this stack? Two pieces look open to me: the single-character Big5/EUC-KR/UHC forms (to and from UCS-2/UTF-16/UTF-32, from the CP949/CP950 tables already on main), and the *ToMbc encode direction that this PR leaves throwing. If you are not, I would pick them up on top of #8976/#8993 once they land, so we do not end up editing the same functions.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6316852112 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8993#issuecomment-6316852112). Originally posted by [rooklz](https://github.com/rooklz) on 2026-10-21T13:08:24Z. --- @simonbronk are you planning to keep going with libSceCesCs after this stack? Two pieces look open to me: the single-character Big5/EUC-KR/UHC forms (to and from UCS-2/UTF-16/UTF-32, from the CP949/CP950 tables already on main), and the `*ToMbc` encode direction that this PR leaves throwing. If you are not, I would pick them up on top of #8976/#8993 once they land, so we do not end up editing the same functions.
simonbronk commented 2026-10-21 13:22:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by simonbronk on 2026-10-21T13:22:38Z.


@rooklz Thanks for asking. I'm not planning to take either piece, so please go ahead with both. Heads-up: dc7be1b07 on main now conflicts with the stack (#8967 → #8972 → #8976 → #8993). I'm resolving that now, so please build on the updated branches once they're pushed.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6317155519 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8993#issuecomment-6317155519). Originally posted by [simonbronk](https://github.com/simonbronk) on 2026-10-21T13:22:38Z. --- @rooklz Thanks for asking. I'm not planning to take either piece, so please go ahead with both. Heads-up: dc7be1b07 on main now conflicts with the stack (#8967 → #8972 → #8976 → #8993). I'm resolving that now, so please build on the updated branches once they're pushed.
rooklz commented 2026-10-21 14:19:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-10-21T14:19:24Z.


Opened #9175 on top of your stack for the *ToMbc encode side, thanks. The Big5/EUC-KR/UHC scalar forms turned out to be in #9107 (jacob6769, opened earlier today on top of main), so I dropped mine; mentioning it since #9107 touches the same parts of Export.cpp and PendingExports.cpp as your stack.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6318371472 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8993#issuecomment-6318371472). Originally posted by [rooklz](https://github.com/rooklz) on 2026-10-21T14:19:24Z. --- Opened #9175 on top of your stack for the `*ToMbc` encode side, thanks. The Big5/EUC-KR/UHC scalar forms turned out to be in #9107 (jacob6769, opened earlier today on top of main), so I dropped mine; mentioning it since #9107 touches the same parts of `Export.cpp` and `PendingExports.cpp` as your stack.
rooklz commented 2026-10-21 14:20:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-10-21T14:20:18Z.


@simonbronk one more question so we do not collide: would you mind if I also took the strict JIS X 0208 profiles (sceCesUcsProfileInitEucJpX0208, ...X0208Ss2, ...X0208Ss2Ss3, sceCesUcsProfileInitSJis1997X0208, from unicode.org JIS0208.TXT) and the GB18030-2000/2005 profiles (ICU gb-18030-*.ucm) after your stack, or are those on your list?

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6318390853 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8993#issuecomment-6318390853). Originally posted by [rooklz](https://github.com/rooklz) on 2026-10-21T14:20:18Z. --- @simonbronk one more question so we do not collide: would you mind if I also took the strict JIS X 0208 profiles (`sceCesUcsProfileInitEucJpX0208`, `...X0208Ss2`, `...X0208Ss2Ss3`, `sceCesUcsProfileInitSJis1997X0208`, from unicode.org `JIS0208.TXT`) and the GB18030-2000/2005 profiles (ICU `gb-18030-*.ucm`) after your stack, or are those on your list?
simonbronk commented 2026-10-21 14:36:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by simonbronk on 2026-10-21T14:36:20Z.


@rooklz Not on my list, so go ahead with both after the stack. Thanks for flagging #9107.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6318689366 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8993#issuecomment-6318689366). Originally posted by [simonbronk](https://github.com/simonbronk) on 2026-10-21T14:36:20Z. --- @rooklz Not on my list, so go ahead with both after the stack. Thanks for flagging #9107.
ycbuzi commented 2026-10-21 17:51:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ycbuzi on 2026-10-21T17:51:24Z.


Windows run of c020ce8934 merged onto main 80565c5942 (40b4bd217e, clean), the platform the description lists as not tested. Windows 11 Home 10.0.26200, MinGW-w64 GCC 15.2.0 (ucrt-posix-seh r7), Release, BUILD_TESTING=ON.

Built libSceCesCs, libSceCesCs-module and the 13 test executables with no errors or warnings. ctest --repeat until-fail:2 on the 13 tests these executables register on Windows: all pass on both repeats. The 13 are the guest_ces_* tests other than the base guest_ces, the new guest_ces_mbc and guest_ces_mbc_module among them. The head carries the stack below it (#8967, #8972, #8976) too. Not run: a title.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6322744549 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8993#issuecomment-6322744549). Originally posted by [ycbuzi](https://github.com/ycbuzi) on 2026-10-21T17:51:24Z. --- Windows run of c020ce8934 merged onto `main` 80565c5942 (40b4bd217e, clean), the platform the description lists as not tested. Windows 11 Home 10.0.26200, MinGW-w64 GCC 15.2.0 (ucrt-posix-seh r7), Release, `BUILD_TESTING=ON`. Built `libSceCesCs`, `libSceCesCs-module` and the 13 test executables with no errors or warnings. `ctest --repeat until-fail:2` on the 13 tests these executables register on Windows: all pass on both repeats. The 13 are the `guest_ces_*` tests other than the base `guest_ces`, the new `guest_ces_mbc` and `guest_ces_mbc_module` among them. The head carries the stack below it (#8967, #8972, #8976) too. Not run: a title.
simonbronk commented 2026-10-21 18:17:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by simonbronk on 2026-10-21T18:17:01Z.


Linux run of c020ce893 merged onto main 99844c7ee (clean merge).

Environment: Ubuntu 24.04 x86-64 container under Rosetta on Apple Silicon (Colima), GCC 13, RelWithDebInfo, BUILD_TESTING=ON, ANYPS5_ENABLE_ASAN=ON. ASan builds dynamic executables, so this is not the CI configuration.

Results: the full build has no errors. guest_ces, guest_ces_chinese, guest_ces_dbcs, guest_ces_japanese, guest_ces_mbc, guest_ces_unicode, guest_ces_wide and their module forms: all pass, with no AddressSanitizer report.

Not run: the static CI configuration, native x86-64 hardware, GPU tests, a title.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6323254954 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8993#issuecomment-6323254954). Originally posted by [simonbronk](https://github.com/simonbronk) on 2026-10-21T18:17:01Z. --- Linux run of c020ce893 merged onto `main` 99844c7ee (clean merge). **Environment:** Ubuntu 24.04 x86-64 container under Rosetta on Apple Silicon (Colima), GCC 13, `RelWithDebInfo`, `BUILD_TESTING=ON`, `ANYPS5_ENABLE_ASAN=ON`. ASan builds dynamic executables, so this is not the CI configuration. **Results:** the full build has no errors. `guest_ces`, `guest_ces_chinese`, `guest_ces_dbcs`, `guest_ces_japanese`, `guest_ces_mbc`, `guest_ces_unicode`, `guest_ces_wide` and their module forms: all pass, with no AddressSanitizer report. **Not run:** the static CI configuration, native x86-64 hardware, GPU tests, a title. 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!8993
No description provided.