feat(libSceCesCs): add 27 single-byte code page profiles #8923

Merged
nikowolf123 merged 2 commits from upstream-pr/8923 into main 2026-10-23 02:47:12 +00:00
nikowolf123 commented 2026-10-21 06:15:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by nikowolf123 on 2026-10-21T06:15:35Z.


What

sceCesRefersUcsProfile* threw not implemented for every code page except 1250, 1251 and 1252. 27 more now return a profile, like the existing three. sceCesSbcToUtf8, sceCesUtf8ToSbc and the MBCS context conversions (sceCesMbcsUcsContextInit with sceCesUtf8StrToMbcsStr, sceCesMbcsStrToUtf8Str, sceCesUcs2StrToMbcsStr and the others) accept these profiles:

Family Profiles Source of the high half (bytes 0x80-0xFF)
ISO 8859 Iso8859_1, _2, _4, _5, _9, _10, _13, _14, _15, _16 unicode.org ISO8859/8859-n.TXT
DOS code pages Cp437, Cp737, Cp775, Cp850, Cp852, Cp855, Cp860, Cp861, Cp862, Cp863, Cp865, Cp866 Microsoft's PC tables, VENDORS/MICSFT/PC/CPnnn.TXT
KOI8 Koi8R, Koi8U VENDORS/MISC/KOI8-R.TXT and KOI8-U.TXT
Windows Cp1254, Cp1256, Cp1258 Microsoft's best-fit tables, bestfitnnnn.txt, byte table (MBTABLE)
  • Signatures: const struct* sceCesRefersUcsProfileXxx(void) for all of them, as in the Orbital type database that the library already cites for 1250-1252.
  • Same derivation as the existing tables: the high half of main's CP1250_HIGH is byte for byte the MBTABLE of bestfit1250.txt, and 1254, 1256 and 1258 are taken the same way. Their unassigned bytes map to the C1 control characters, as in the 1250 table.
  • Table properties: in every new table, bytes 0x00-0x7F map to themselves, and the 256 bytes map to 256 different BMP characters. So the reverse direction (sceCesUtf8ToSbc, MBCS output) is unambiguous, and a character outside the table returns UNASSIGNED_CODE (0x805C0020) through the existing code.
  • Code: the tables are in the new core/libs/prx/libSceCesCs/SingleByte.hpp, generated from those files. Export.cpp gets one lookup (sbcHighTable) that sbcToUnicode, unicodeToSbc and isSbc now use for 1250, 1251 and the new profiles. 1252 keeps its own path, and the three existing profiles keep their pointers and tables.
  • Not included, still throwing: the code pages whose public table leaves bytes undefined (ISO 8859-3, -6, -7, -8 and -11; 857, 864 and 869), the best-fit tables that map bytes to private-use characters (874, 1253, 1255 and 1257), and the profiles without a public table here (858, Ascii, AsciiWithKatakana, Bs4730, the five JisX0201*, the two KsX1003* and the two GbT1988*). For those, AnyPS5 would have to guess what the console does with the undefined bytes.
  • Unverified: the console's tables are not checked. This is recorded as a new "Single-byte profiles" entry in docs/dev/debt/libSceCesCs.md, and the pending-exports count there drops from 249 to 222.
  • Overlap: #7884 (EUC-KR, UHC and Big5) is merged and this branch is rebased onto it; its isMbcs, decodeMbcs and encodeMbcs reach the new profiles through isSbc. Open #8967, #8972, #8976, #8993, #9107 and #9175 also change Export.cpp, PendingExports.cpp or the pending-exports count in the debt file, so whichever merges after this PR recounts that figure. #8804, which overlapped on the include block of Export.cpp and the helpers before main() in GuestCes.cpp, was closed in favour of #7884. No open PR implements any of the 27.

Tested

Linux: WSL2 Ubuntu 26.04, GCC 15.2.0 (Ubuntu 15.2.0-16ubuntu1), Release. I built libSceCesCs, guest_ces_tests and guest_ces_module_tests and ran ctest -R '^guest_ces(_module)?$': guest_ces and guest_ces_module pass (2/2) at 0b3f33955, on main ec7eacc62. After the rebase onto main 2c4b116da, at 27c3f6ba2, I built libs and the six guest_ces* test targets: ctest -R '^guest_ces' passes 6/6 (guest_ces, guest_ces_module, guest_ces_dbcs, guest_ces_dbcs_module, guest_ces_unicode and guest_ces_unicode_module). Export.cpp and GuestCes.cpp compile without warnings in both builds.

guest_ces (and guest_ces_module, the same test against the module build) now runs CheckSingleByteProfiles(). For each of the 27 profiles it checks:

  • that the profile is a non-null pointer, stable across calls, and different from the other 29 profiles;
  • that every byte 1-255 converts with sceCesSbcToUtf8, bytes below 0x80 to themselves, and converts back to the same byte with sceCesUtf8ToSbc;
  • that U+3042 returns UNASSIGNED_CODE;
  • four bytes per table (0x80, 0xA4, 0xC1 and 0xFF) against the code point in the source file.

It also checks a KOI8-R string through an MBCS context: "Привет" converts to F0 D2 C9 D7 C5 D4 and back. On main the first new call throws not implemented, so the test fails there.

tools/check_conventions.py --base origin/main passes. tools/progress.py --module libSceCesCs goes from 38 to 65 done functions out of 287 on main 2c4b116da; the new ones are exactly these 27.

Windows: not built. No title was run.

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

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4947269854 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8923). Originally posted by [nikowolf123](https://github.com/nikowolf123) on 2026-10-21T06:15:35Z. --- ### What `sceCesRefersUcsProfile*` threw `not implemented` for every code page except 1250, 1251 and 1252. 27 more now return a profile, like the existing three. `sceCesSbcToUtf8`, `sceCesUtf8ToSbc` and the MBCS context conversions (`sceCesMbcsUcsContextInit` with `sceCesUtf8StrToMbcsStr`, `sceCesMbcsStrToUtf8Str`, `sceCesUcs2StrToMbcsStr` and the others) accept these profiles: | Family | Profiles | Source of the high half (bytes 0x80-0xFF) | |---|---|---| | ISO 8859 | `Iso8859_1`, `_2`, `_4`, `_5`, `_9`, `_10`, `_13`, `_14`, `_15`, `_16` | [unicode.org ISO8859/8859-n.TXT](https://unicode.org/Public/MAPPINGS/ISO8859/) | | DOS code pages | `Cp437`, `Cp737`, `Cp775`, `Cp850`, `Cp852`, `Cp855`, `Cp860`, `Cp861`, `Cp862`, `Cp863`, `Cp865`, `Cp866` | [Microsoft's PC tables, VENDORS/MICSFT/PC/CPnnn.TXT](https://unicode.org/Public/MAPPINGS/VENDORS/MICSFT/PC/) | | KOI8 | `Koi8R`, `Koi8U` | [VENDORS/MISC/KOI8-R.TXT and KOI8-U.TXT](https://unicode.org/Public/MAPPINGS/VENDORS/MISC/) | | Windows | `Cp1254`, `Cp1256`, `Cp1258` | [Microsoft's best-fit tables, bestfitnnnn.txt](https://unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WindowsBestFit/), byte table (`MBTABLE`) | - **Signatures:** `const struct* sceCesRefersUcsProfileXxx(void)` for all of them, as in the [Orbital type database](https://github.com/AlexAltea/orbital/blob/b321fcdbd700cc02da1cb1ad25412781d5ec73c6/tools/ida/db_types.json) that the library already cites for 1250-1252. - **Same derivation as the existing tables:** the high half of `main`'s `CP1250_HIGH` is byte for byte the `MBTABLE` of `bestfit1250.txt`, and 1254, 1256 and 1258 are taken the same way. Their unassigned bytes map to the C1 control characters, as in the 1250 table. - **Table properties:** in every new table, bytes 0x00-0x7F map to themselves, and the 256 bytes map to 256 different BMP characters. So the reverse direction (`sceCesUtf8ToSbc`, MBCS output) is unambiguous, and a character outside the table returns `UNASSIGNED_CODE` (`0x805C0020`) through the existing code. - **Code:** the tables are in the new `core/libs/prx/libSceCesCs/SingleByte.hpp`, generated from those files. `Export.cpp` gets one lookup (`sbcHighTable`) that `sbcToUnicode`, `unicodeToSbc` and `isSbc` now use for 1250, 1251 and the new profiles. 1252 keeps its own path, and the three existing profiles keep their pointers and tables. - **Not included, still throwing:** the code pages whose public table leaves bytes undefined (ISO 8859-3, -6, -7, -8 and -11; 857, 864 and 869), the best-fit tables that map bytes to private-use characters (874, 1253, 1255 and 1257), and the profiles without a public table here (858, `Ascii`, `AsciiWithKatakana`, `Bs4730`, the five `JisX0201*`, the two `KsX1003*` and the two `GbT1988*`). For those, AnyPS5 would have to guess what the console does with the undefined bytes. - **Unverified:** the console's tables are not checked. This is recorded as a new "Single-byte profiles" entry in `docs/dev/debt/libSceCesCs.md`, and the pending-exports count there drops from 249 to 222. - **Overlap:** #7884 (EUC-KR, UHC and Big5) is merged and this branch is rebased onto it; its `isMbcs`, `decodeMbcs` and `encodeMbcs` reach the new profiles through `isSbc`. Open #8967, #8972, #8976, #8993, #9107 and #9175 also change `Export.cpp`, `PendingExports.cpp` or the pending-exports count in the debt file, so whichever merges after this PR recounts that figure. #8804, which overlapped on the include block of `Export.cpp` and the helpers before `main()` in `GuestCes.cpp`, was closed in favour of #7884. No open PR implements any of the 27. ### 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: WSL2 Ubuntu 26.04, GCC 15.2.0 (Ubuntu 15.2.0-16ubuntu1), Release. I built `libSceCesCs`, `guest_ces_tests` and `guest_ces_module_tests` and ran `ctest -R '^guest_ces(_module)?$'`: `guest_ces` and `guest_ces_module` pass (2/2) at 0b3f33955, on `main` ec7eacc62. After the rebase onto `main` 2c4b116da, at 27c3f6ba2, I built `libs` and the six `guest_ces*` test targets: `ctest -R '^guest_ces'` passes 6/6 (`guest_ces`, `guest_ces_module`, `guest_ces_dbcs`, `guest_ces_dbcs_module`, `guest_ces_unicode` and `guest_ces_unicode_module`). `Export.cpp` and `GuestCes.cpp` compile without warnings in both builds. `guest_ces` (and `guest_ces_module`, the same test against the module build) now runs `CheckSingleByteProfiles()`. For each of the 27 profiles it checks: - that the profile is a non-null pointer, stable across calls, and different from the other 29 profiles; - that every byte 1-255 converts with `sceCesSbcToUtf8`, bytes below 0x80 to themselves, and converts back to the same byte with `sceCesUtf8ToSbc`; - that U+3042 returns `UNASSIGNED_CODE`; - four bytes per table (0x80, 0xA4, 0xC1 and 0xFF) against the code point in the source file. It also checks a KOI8-R string through an MBCS context: "Привет" converts to `F0 D2 C9 D7 C5 D4` and back. On `main` the first new call throws `not implemented`, so the test fails there. `tools/check_conventions.py --base origin/main` passes. `tools/progress.py --module libSceCesCs` goes from 38 to 65 done functions out of 287 on `main` 2c4b116da; the new ones are exactly these 27. Windows: not built. No title was run. ### 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: <!-- #PR, or none --> none - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> n/a - [x] AI-assisted: <!-- yes / no --> yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-10-21 06:19:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T06:19:27Z.

Review: APPROVED


I reviewed the profile dispatch and generated tables. I independently compared every high-half entry in all 27 tables against the corresponding Python ISO-8859, CP, and KOI8 codecs (treating undefined CP125x bytes as C1 controls, as documented); all entries matched. The tables remain one-to-one with the ASCII low half. The PR’s focused Linux tests and convention check are author-reported; I did not rerun the guest tests. The current conventions/report checks pass, and I found no duplicate profile implementation.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5595680360 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8923#pullrequestreview-5595680360). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-21T06:19:27Z. **Review:** APPROVED --- I reviewed the profile dispatch and generated tables. I independently compared every high-half entry in all 27 tables against the corresponding Python ISO-8859, CP, and KOI8 codecs (treating undefined CP125x bytes as C1 controls, as documented); all entries matched. The tables remain one-to-one with the ASCII low half. The PR’s focused Linux tests and convention check are author-reported; I did not rerun the guest tests. The current conventions/report checks pass, and I found no duplicate profile implementation.
ycbuzi commented 2026-10-21 07:35:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ycbuzi on 2026-10-21T07:35:19Z.


Windows run of 0b3f339556 merged onto main b77bd58806 (1e27b5f5bd), the build the description lists as not done. 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 four guest_ces* test executables with no errors or warnings; ctest --repeat until-fail:2 on guest_ces, guest_ces_module, guest_ces_unicode and guest_ces_unicode_module: all pass on both repeats. Not run: the negative control against main's library, a title.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6310653393 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8923#issuecomment-6310653393). Originally posted by [ycbuzi](https://github.com/ycbuzi) on 2026-10-21T07:35:19Z. --- Windows run of 0b3f339556 merged onto `main` b77bd58806 (1e27b5f5bd), the build the description lists as not done. 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 four `guest_ces*` test executables with no errors or warnings; `ctest --repeat until-fail:2` on `guest_ces`, `guest_ces_module`, `guest_ces_unicode` and `guest_ces_unicode_module`: all pass on both repeats. Not run: the negative control against `main`'s library, a title.
rooklz commented 2026-10-21 14:20:15 +00:00 (Migrated from github.com)

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


@nikowolf123 nice work on the single-byte profiles. I agree with leaving the pages with undefined bytes alone. Two groups you left out look fully defined to me, though: CP858 (no undefined bytes; ICU ibm-858_P100-1997.ucm), and the 7-bit ISO 646 / JIS X 0201 sets with published tables (Ascii, Bs4730, GbT1988 and its tilde variant, JisX0201, JisX0201Roman and their tilde variants, from unicode.org JIS0201.TXT and the glibc charmaps in icu-data). Are you planning those? If not, I would do them on top of this PR once it lands and leave KsX1003*, AsciiWithKatakana and JisX0201Katakana throwing, since their contents are not settled.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6318390031 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8923#issuecomment-6318390031). Originally posted by [rooklz](https://github.com/rooklz) on 2026-10-21T14:20:15Z. --- @nikowolf123 nice work on the single-byte profiles. I agree with leaving the pages with undefined bytes alone. Two groups you left out look fully defined to me, though: CP858 (no undefined bytes; ICU `ibm-858_P100-1997.ucm`), and the 7-bit ISO 646 / JIS X 0201 sets with published tables (`Ascii`, `Bs4730`, `GbT1988` and its tilde variant, `JisX0201`, `JisX0201Roman` and their tilde variants, from unicode.org `JIS0201.TXT` and the glibc charmaps in icu-data). Are you planning those? If not, I would do them on top of this PR once it lands and leave `KsX1003*`, `AsciiWithKatakana` and `JisX0201Katakana` throwing, since their contents are not settled.
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!8923
No description provided.