feat(libSceCesCs): convert GBK and EUC-CN through the CP936 table #8976

Merged
simonbronk merged 4 commits from upstream-pr/8976 into main 2026-10-23 11:29:11 +00:00
simonbronk commented 2026-10-21 08:11:47 +00:00 (Migrated from github.com)

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


What

Implements 34 libSceCesCs exports that were pending stubs:

  • sceCesUcsProfileInitGbkCp936, sceCesUcsProfileInitEucCnGb2312
  • sceCesGbTo{Ucs2,Utf8,Utf16,Utf16be,Utf16le,Utf32,Utf32be,Utf32le} and sceCesEucCnTo{…}
  • sceCes{Ucs2,Utf8,Utf16,Utf16be,Utf16le,Utf32,Utf32be,Utf32le}ToGb and …ToEucCn

The new Cp936.hpp holds the 21,791 double-byte cells of Microsoft's CP936.TXT, with single-byte 0x80 mapped to U+20AC as that file does. The GB 2312 mapping file is no longer published by unicode.org, so the EUC-CN profile uses the same table restricted to 0xA1-0xFE lead and trail bytes; the differences this implies (GBK cells inside that range, CP936 forms of 0xA1A4 and 0xA1AA) are recorded in docs/dev/debt/libSceCesCs.md. The MBCS string conversions (sceCesUtf8StrToMbcsStr and the others) accept both profiles. The scalar helpers from #8967 are renamed from *Japanese to *Profiled because they now serve both languages. Signatures follow the Orbital type database. Errors follow the existing converters and are not console measurements. User-defined areas, GB 18030 four-byte forms and sceCesGbUcsProfileSet* stay unimplemented. libSceCesCs goes from 86 to 120 of 284 in tools/progress.py.

This branch is stacked on #8972 (itself on #8967); only the top commit is new.

Tested

macOS 27 (Apple silicon), clang, C++20: libSceCesCs sources and tests compiled outside CMake, since the full build does not run on macOS. Passing:

  • new guest_ces_chinese: errors, byte orders, a GBK and EUC-CN round trip of every encodable BMP code point, and GBK strings through an MBCS context;
  • existing guest_ces, guest_ces_unicode, guest_ces_japanese and guest_ces_wide, with no regressions.

Cross-check: sceCesGbToUcs2 on all 32,766 lead/trail pairs matches Python's gbk codec (24,066 identical decodes; all other pairs fail in both).

The CMake/ctest build on Linux and Windows was not run locally. check_conventions.py is clean. pr_overlap.py lists only shared files with #8923, #7884 and #6044, none implementing these functions; #7884 edits the same MBCS dispatch in Export.cpp, so whichever lands second needs a rebase. No title tested.

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

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4948481183 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8976). Originally posted by [simonbronk](https://github.com/simonbronk) on 2026-10-21T08:11:47Z. --- ### What Implements 34 libSceCesCs exports that were pending stubs: - `sceCesUcsProfileInitGbkCp936`, `sceCesUcsProfileInitEucCnGb2312` - `sceCesGbTo{Ucs2,Utf8,Utf16,Utf16be,Utf16le,Utf32,Utf32be,Utf32le}` and `sceCesEucCnTo{…}` - `sceCes{Ucs2,Utf8,Utf16,Utf16be,Utf16le,Utf32,Utf32be,Utf32le}ToGb` and `…ToEucCn` The new `Cp936.hpp` holds the 21,791 double-byte cells of Microsoft's [CP936.TXT](https://unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP936.TXT), with single-byte `0x80` mapped to U+20AC as that file does. The GB 2312 mapping file is no longer published by unicode.org, so the EUC-CN profile uses the same table restricted to `0xA1`-`0xFE` lead and trail bytes; the differences this implies (GBK cells inside that range, CP936 forms of `0xA1A4` and `0xA1AA`) are recorded in `docs/dev/debt/libSceCesCs.md`. The MBCS string conversions (`sceCesUtf8StrToMbcsStr` and the others) accept both profiles. The scalar helpers from #8967 are renamed from `*Japanese` to `*Profiled` because they now serve both languages. Signatures follow the Orbital type database. Errors follow the existing converters and are not console measurements. User-defined areas, GB 18030 four-byte forms and `sceCesGbUcsProfileSet*` stay unimplemented. libSceCesCs goes from 86 to 120 of 284 in `tools/progress.py`. This branch is stacked on #8972 (itself on #8967); only the top commit is new. ### Tested macOS 27 (Apple silicon), clang, C++20: libSceCesCs sources and tests compiled outside CMake, since the full build does not run on macOS. Passing: - new `guest_ces_chinese`: errors, byte orders, a GBK and EUC-CN round trip of every encodable BMP code point, and GBK strings through an MBCS context; - existing `guest_ces`, `guest_ces_unicode`, `guest_ces_japanese` and `guest_ces_wide`, with no regressions. Cross-check: `sceCesGbToUcs2` on all 32,766 lead/trail pairs matches Python's `gbk` codec (24,066 identical decodes; all other pairs fail in both). The CMake/ctest build on Linux and Windows was not run locally. `check_conventions.py` is clean. `pr_overlap.py` lists only shared files with #8923, #7884 and #6044, none implementing these functions; #7884 edits the same MBCS dispatch in `Export.cpp`, so whichever lands second needs a rebase. No title tested. ### 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: #8972 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
ycbuzi commented 2026-10-21 08:28:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ycbuzi on 2026-10-21T08:28:23Z.


Windows run of a4049f3c3f merged cleanly onto main f894ba69d3, the CMake/ctest build the description lists as not run. The head carries the commits of #8967 and #8972 too. Windows 11 Home 10.0.26200, MinGW-w64 GCC 15.2.0 (ucrt-posix-seh r7), Release, BUILD_TESTING=ON.

Built libSceCesCs, its module form and the ten test executables with no errors or warnings. ctest --repeat until-fail:2 on guest_ces, guest_ces_module, guest_ces_unicode, guest_ces_unicode_module, guest_ces_japanese, guest_ces_japanese_module, guest_ces_wide, guest_ces_wide_module, guest_ces_chinese and guest_ces_chinese_module: all ten pass on both repeats, the new guest_ces_chinese and its module form among them. Not run: Linux, a title.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6311563292 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8976#issuecomment-6311563292). Originally posted by [ycbuzi](https://github.com/ycbuzi) on 2026-10-21T08:28:23Z. --- Windows run of a4049f3c3f merged cleanly onto `main` f894ba69d3, the CMake/ctest build the description lists as not run. The head carries the commits of #8967 and #8972 too. Windows 11 Home 10.0.26200, MinGW-w64 GCC 15.2.0 (ucrt-posix-seh r7), Release, `BUILD_TESTING=ON`. Built `libSceCesCs`, its module form and the ten test executables with no errors or warnings. `ctest --repeat until-fail:2` on `guest_ces`, `guest_ces_module`, `guest_ces_unicode`, `guest_ces_unicode_module`, `guest_ces_japanese`, `guest_ces_japanese_module`, `guest_ces_wide`, `guest_ces_wide_module`, `guest_ces_chinese` and `guest_ces_chinese_module`: all ten pass on both repeats, the new `guest_ces_chinese` and its module form among them. Not run: Linux, a title.
clairtonmichel commented 2026-10-21 08:43:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by clairtonmichel on 2026-10-21T08:43:43Z.


Tested on AMD Ryzen 7 9800X3D and AMD Radeon RX 7900 XTX (Fedora Linux, Mesa 26.2.5):

  • Built cleanly without any errors.
  • Ran the localization and charset conversion test suite (including guest_ces_chinese, unicode, and module tests): 100% passed successfully (48/48 tests green).
  • GBK and EUC-CN CP936 conversion routines work flawlessly on host. Great contribution!
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6311841099 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8976#issuecomment-6311841099). Originally posted by [clairtonmichel](https://github.com/clairtonmichel) on 2026-10-21T08:43:43Z. --- Tested on AMD Ryzen 7 9800X3D and AMD Radeon RX 7900 XTX (Fedora Linux, Mesa 26.2.5): - Built cleanly without any errors. - Ran the localization and charset conversion test suite (including `guest_ces_chinese`, unicode, and module tests): **100% passed successfully** (48/48 tests green). - GBK and EUC-CN CP936 conversion routines work flawlessly on host. Great contribution!
simonbronk commented 2026-10-21 18:16:56 +00:00 (Migrated from github.com)

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


Linux run of f974e91f0 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_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:6323253156 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8976#issuecomment-6323253156). Originally posted by [simonbronk](https://github.com/simonbronk) on 2026-10-21T18:16:56Z. --- Linux run of f974e91f0 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_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).
ycbuzi commented 2026-10-22 08:34:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ycbuzi on 2026-10-22T08:34:26Z.


Windows run of f974e91f08, the update since my earlier run, merged onto main d6eafa54d0 (1d6ee41de0, clean). Windows 11 Home 10.0.26200, MinGW-w64 GCC 15.2.0 (ucrt-posix-seh r7), Release, BUILD_TESTING=ON.

Built libSceCesCs, its module form and the ten test executables with no errors or warnings. ctest --repeat until-fail:2 on guest_ces, guest_ces_module, guest_ces_unicode, guest_ces_unicode_module, guest_ces_japanese, guest_ces_japanese_module, guest_ces_wide, guest_ces_wide_module, guest_ces_chinese and guest_ces_chinese_module: all ten pass on both repeats. Not run: a title.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6336425845 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8976#issuecomment-6336425845). Originally posted by [ycbuzi](https://github.com/ycbuzi) on 2026-10-22T08:34:26Z. --- Windows run of f974e91f08, the update since my earlier run, merged onto `main` d6eafa54d0 (1d6ee41de0, clean). Windows 11 Home 10.0.26200, MinGW-w64 GCC 15.2.0 (ucrt-posix-seh r7), Release, `BUILD_TESTING=ON`. Built `libSceCesCs`, its module form and the ten test executables with no errors or warnings. `ctest --repeat until-fail:2` on `guest_ces`, `guest_ces_module`, `guest_ces_unicode`, `guest_ces_unicode_module`, `guest_ces_japanese`, `guest_ces_japanese_module`, `guest_ces_wide`, `guest_ces_wide_module`, `guest_ces_chinese` and `guest_ces_chinese_module`: all ten pass on both repeats. Not run: a title.
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!8976
No description provided.