feat(libSceCesCs): implement EUC-KR, UHC and Big5 to UTF-8 conversions #8804

Closed
r1p0N wants to merge 1 commit from upstream-pr/8804 into main
r1p0N commented 2026-10-21 01:28:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by r1p0N on 2026-10-21T01:28:06Z.


What

Adds sceCesUcsProfileInitEucKr, sceCesUcsProfileInitUhc and sceCesUcsProfileInitBig5Cp950, and replaces the unimplemented sceCesEucKrToUtf8, sceCesUhcToUtf8 and sceCesBig5ToUtf8 with one-character conversions that follow sceCesEucJpToUtf8. Tables: [EucKr.hpp, Uhc.hpp, Big5.hpp], matching Python's euc_kr/cp949/cp950 codecs cell by cell. Console behaviour and signatures are unverified and listed in the libSceCesCs technical debt.

Tested

Linux x86-64, GCC 13.3: libSceCesCs sources plus the extended GuestCes.cpp test compiled directly with -std=c++20 -Wall -Wextra; passes. Also run under AddressSanitizer and UBSan: no reports in the new code. Not built through the full CMake build; not tested on a console or with any title.
Note: ASan also reports a pre-existing over-read in isEucJp (and by the same pattern isSjis) when a single-byte profile reaches sceCesMbcsStrToUtf8Str; not changed here.

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

🤖 Generated with Claude Code

https://claude.ai/code/session_017Tkt8gmGLazgLCTf4MNpkG

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4944970985 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8804). Originally posted by [r1p0N](https://github.com/r1p0N) on 2026-10-21T01:28:06Z. --- ### What Adds `sceCesUcsProfileInitEucKr`, `sceCesUcsProfileInitUhc` and `sceCesUcsProfileInitBig5Cp950`, and replaces the unimplemented `sceCesEucKrToUtf8`, `sceCesUhcToUtf8` and `sceCesBig5ToUtf8` with one-character conversions that follow `sceCesEucJpToUtf8`. Tables: [EucKr.hpp, Uhc.hpp, Big5.hpp], matching Python's euc_kr/cp949/cp950 codecs cell by cell. Console behaviour and signatures are unverified and listed in the libSceCesCs technical debt. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Linux x86-64, GCC 13.3: libSceCesCs sources plus the extended `GuestCes.cpp` test compiled directly with `-std=c++20 -Wall -Wextra`; passes. Also run under AddressSanitizer and UBSan: no reports in the new code. Not built through the full CMake build; not tested on a console or with any title. Note: ASan also reports a pre-existing over-read in `isEucJp` (and by the same pattern `isSjis`) when a single-byte profile reaches `sceCesMbcsStrToUtf8Str`; not changed here. ### 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 --> 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_017Tkt8gmGLazgLCTf4MNpkG
github-actions[bot] commented 2026-10-21 01:42:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-21T01:42:23Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 7884 sceCesUcsProfileInitBig5Cp950
sceCesUcsProfileInitEucKr
sceCesUcsProfileInitUhc
PR 8923 core/libs/prx/libSceCesCs/Export.cpp L10
core/libs/tests/GuestCes.cpp L48

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 6044 core/libs/tests/GuestCes.cpp
PR 7884 core/libs/prx/libSceCesCs/Export.cpp
docs/dev/debt/libSceCesCs.md
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6305917206 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8804#issuecomment-6305917206). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-21T01:42:23Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | [PR 7884](https://www.github.com/boykopovar/AnyPS5/pull/7884) | | `sceCesUcsProfileInitBig5Cp950`<br>`sceCesUcsProfileInitEucKr`<br>`sceCesUcsProfileInitUhc` | | | [PR 8923](https://www.github.com/boykopovar/AnyPS5/pull/8923) | `core/libs/prx/libSceCesCs/Export.cpp` [L10](https://github.com/boykopovar/AnyPS5/blob/0aa55ef293e17ea0fa624e2fb601fb5b1a979b27/core/libs/prx/libSceCesCs/Export.cpp#L10)<br>`core/libs/tests/GuestCes.cpp` [L48](https://github.com/boykopovar/AnyPS5/blob/0aa55ef293e17ea0fa624e2fb601fb5b1a979b27/core/libs/tests/GuestCes.cpp#L48) | | | Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/tests/GuestCes.cpp` | | [PR 7884](https://www.github.com/boykopovar/AnyPS5/pull/7884) | `core/libs/prx/libSceCesCs/Export.cpp`<br>`docs/dev/debt/libSceCesCs.md` |
nikowolf123 commented 2026-10-21 03:18:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by nikowolf123 on 2026-10-21T03:18:49Z.


Big5 table decodes a block that CP950 leaves user-defined. Rows C6 and C7 of Big5.hpp map 249 cells in C6A1-C7FC. For example, sceCesBig5ToUtf8(big5, "\xC6\xA1", 2, ...) returns 0 with U+30FE, and "\xC7\xB1" gives U+0414. Microsoft's CP950.TXT has no entry in that range, and bestfit950.txt marks it EUDC (0xa1 0xf6b1 ;EUDC under lead byte 0xc6). Apart from these 249 cells, the table equals CP950.TXT: all 13,503 double-byte entries, with the same values.

The block comes from CPython. Its cp950 decoder falls back to the big5 map when cp950ext has no entry (_codecs_tw.c). The other user-defined ranges (8140, FA40, C8A1) answer UNASSIGNED_CODE. The debt entry says the tables follow Microsoft's code pages.

I would zero those 249 cells, change the count in GuestCes.cpp to 13503, and add Require(DoubleByteStatus(big5Convert, big5, "\xC6\xA1", 2) == unassignedCode);. If the block is meant to stay, the debt entry should say that C6A1-C7FC follow CPython's big5 table, not CP950.

The new profiles silently fail in the MBCS string conversions. toMbcs and fromMbcs still accept only the EUC-JP, Shift-JIS and single-byte profiles (Export.cpp#L432, #L459). After sceCesUcsProfileInitUhc(sheet) and sceCesMbcsUcsContextInit(ctx, sheet), even sceCesMbcsStrToUtf8Str(ctx, "AB", 2, ...) returns 0x805C0001, with no log and no throw. EUC-KR and Big5 behave the same, in both directions and in the Get*Len forms. On main, a title that imports these inits stops at the unresolved import instead.

Orbital gives the three inits the same type as sceCesUcsProfileInitEucJpCp51932: union* (SceCesUcsProfileSheet* sheet) (db_types.json). These functions accept the EUC-JP profile. The debt entry lists this behaviour under Silent stubs, but CONTRIBUTING.md allows a silent stub only when it unblocks a title, and the PR says Unblocks: none.

The decoders already exist. decodeMbcs can dispatch to them, and fromMbcs can accept the three tags:

if (hasTag(profile, EUC_KR_TAG)) return decodeEucKr(mbcs, mbcsMax, length, code);
if (hasTag(profile, UHC_TAG)) return decodeUhc(mbcs, mbcsMax, length, code);
if (hasTag(profile, BIG5_TAG)) return decodeBig5(mbcs, mbcsMax, length, code);

For the *ToMbcsStr direction, toMbcs can use a reverse lookup like jisReverse(), or call NotImplemented_nid_no_patch for these three profiles until it has one. With that change, the PR's GuestCes test still passes in a local build, and UHC B0A1 converts to EA B0 80 through the context.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6307175460 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8804#issuecomment-6307175460). Originally posted by [nikowolf123](https://github.com/nikowolf123) on 2026-10-21T03:18:49Z. --- **Big5 table decodes a block that CP950 leaves user-defined.** Rows C6 and C7 of [Big5.hpp](https://github.com/boykopovar/AnyPS5/blob/be10346f8523f383e3de0fc91b8fa1da86bdbd71/core/libs/prx/libSceCesCs/Big5.hpp#L77-L78) map 249 cells in C6A1-C7FC. For example, `sceCesBig5ToUtf8(big5, "\xC6\xA1", 2, ...)` returns 0 with U+30FE, and `"\xC7\xB1"` gives U+0414. Microsoft's [CP950.TXT](https://unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP950.TXT) has no entry in that range, and [bestfit950.txt](https://unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WindowsBestFit/bestfit950.txt) marks it EUDC (`0xa1 0xf6b1 ;EUDC` under lead byte 0xc6). Apart from these 249 cells, the table equals CP950.TXT: all 13,503 double-byte entries, with the same values. The block comes from CPython. Its `cp950` decoder falls back to the `big5` map when `cp950ext` has no entry ([_codecs_tw.c](https://github.com/python/cpython/blob/main/Modules/cjkcodecs/_codecs_tw.c)). The other user-defined ranges (`8140`, `FA40`, `C8A1`) answer `UNASSIGNED_CODE`. The [debt entry](https://github.com/boykopovar/AnyPS5/blob/be10346f8523f383e3de0fc91b8fa1da86bdbd71/docs/dev/debt/libSceCesCs.md?plain=1#L14) says the tables follow Microsoft's code pages. I would zero those 249 cells, change the count in [GuestCes.cpp](https://github.com/boykopovar/AnyPS5/blob/be10346f8523f383e3de0fc91b8fa1da86bdbd71/core/libs/tests/GuestCes.cpp#L464) to 13503, and add `Require(DoubleByteStatus(big5Convert, big5, "\xC6\xA1", 2) == unassignedCode);`. If the block is meant to stay, the debt entry should say that C6A1-C7FC follow CPython's big5 table, not CP950. **The new profiles silently fail in the MBCS string conversions.** `toMbcs` and `fromMbcs` still accept only the EUC-JP, Shift-JIS and single-byte profiles ([Export.cpp#L432](https://github.com/boykopovar/AnyPS5/blob/be10346f8523f383e3de0fc91b8fa1da86bdbd71/core/libs/prx/libSceCesCs/Export.cpp#L432), [#L459](https://github.com/boykopovar/AnyPS5/blob/be10346f8523f383e3de0fc91b8fa1da86bdbd71/core/libs/prx/libSceCesCs/Export.cpp#L459)). After `sceCesUcsProfileInitUhc(sheet)` and `sceCesMbcsUcsContextInit(ctx, sheet)`, even `sceCesMbcsStrToUtf8Str(ctx, "AB", 2, ...)` returns `0x805C0001`, with no log and no throw. EUC-KR and Big5 behave the same, in both directions and in the `Get*Len` forms. On main, a title that imports these inits stops at the unresolved import instead. Orbital gives the three inits the same type as `sceCesUcsProfileInitEucJpCp51932`: `union* (SceCesUcsProfileSheet* sheet)` ([db_types.json](https://github.com/AlexAltea/orbital/blob/b321fcdbd700cc02da1cb1ad25412781d5ec73c6/tools/ida/db_types.json)). These functions accept the EUC-JP profile. The debt entry lists this behaviour under Silent stubs, but [CONTRIBUTING.md](https://github.com/boykopovar/AnyPS5/blob/be10346f8523f383e3de0fc91b8fa1da86bdbd71/CONTRIBUTING.md?plain=1#L8) allows a silent stub only when it unblocks a title, and the PR says `Unblocks: none`. The decoders already exist. `decodeMbcs` can dispatch to them, and `fromMbcs` can accept the three tags: ```cpp if (hasTag(profile, EUC_KR_TAG)) return decodeEucKr(mbcs, mbcsMax, length, code); if (hasTag(profile, UHC_TAG)) return decodeUhc(mbcs, mbcsMax, length, code); if (hasTag(profile, BIG5_TAG)) return decodeBig5(mbcs, mbcsMax, length, code); ``` For the `*ToMbcsStr` direction, `toMbcs` can use a reverse lookup like `jisReverse()`, or call `NotImplemented_nid_no_patch` for these three profiles until it has one. With that change, the PR's GuestCes test still passes in a local build, and UHC `B0A1` converts to `EA B0 80` through the context.
r1p0N commented 2026-10-21 07:14:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by r1p0N on 2026-10-21T07:14:27Z.


Closing in favor of #7884, which implements the same EUC-KR/UHC/Big5 exports and already covers the MBCS string conversions and Big5 duplicate-cell handling.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6310314990 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8804#issuecomment-6310314990). Originally posted by [r1p0N](https://github.com/r1p0N) on 2026-10-21T07:14:27Z. --- Closing in favor of #7884, which implements the same EUC-KR/UHC/Big5 exports and already covers the MBCS string conversions and Big5 duplicate-cell handling.

Pull request closed

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!8804
No description provided.