fix(libSceCesCs): encode EUC-JP and Shift-JIS as measured on a PS5 #10186
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10186"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by orezraey on 2026-10-23T12:13:08Z.
What
The EUC-JP and Shift-JIS encoders rejected the JIS forms of characters that CP932 maps to Microsoft forms, and they treated U+0080–U+009F like any other unassigned value.
I measured both encoders on a retail PS5 (firmware 13.60) with homebrew probes, from a payload process loading
libSceCesCs.sprx. Every UCS-2 value from U+0000 to U+FFFF went throughsceCesUcs2StrToMbcsStr, and the probe hashed the result, both lengths and the output bytes. Then I dumped the 256-value blocks whose hash differed from AnyPS5's. The sources and console logs are in this gist (pces10,pces11,pces12).Only blocks 00, 20, 22, 30 and FE differed. On the console:
JIS forms map to the Microsoft cells.
A1F18191A1F28192A1EF818FA2CC81CAA1BD815CA1C28161A1B18150A1DD817CA1C18160Each code point lands on the cell of its Microsoft form, which is what those cells decode to.
C1 controls. EUC-JP writes U+0080–U+009F as single bytes, except U+008E and U+008F, which answer
0x805C0020. It answers0x805C0020for U+000E. Shift-JIS answers0x805C0024for U+0080–U+009F and writes U+000E.Byte order mark. U+FEFF is consumed and writes nothing in both profiles.
With the change, the full sweep matches the console for both profiles. The probe also swept every two-byte Shift-JIS input through
sceCesMbcsStrToUcs2Str(pces13); decoding already matched for all of them, and the test now pins that sweep too, so the debt entry no longer calls Shift-JIS decoding unverified. The NEC-selected preference, such as U+2170 →FCF1/EEEF, was already right.Depends on the MBCS string PR, whose conversion loop this sweep runs through. That branch, and the two scalar PRs under it, are carried until they merge.
On top of #8967.
sceCesUcs2ToSJis,sceCesUcs2ToEucJpand the other scalar encoders from #8967 share the encoder, so they take the measured mappings too. Theguest_ces_japaneseround trip skips the forms that encode to Microsoft cells, since they decode back to the Microsoft code point.Tested
main(f4aabbb122) was merged in:72a2187568. The diff againstmainis now only this PR's JIS encode change (4 files). The 14guest_ces*tests pass three runs in a row on Windows (MinGW) and on Linux (WSL Ubuntu, GCC);public_headersaudit andcheck_conventionspass.Windows 11, MinGW (winlibs).
guest_cespins the hash of the full U+0000–U+FFFF sweep for both profiles and of the Shift-JIS two-byte decoding sweep. It also checks the aliases, U+FEFF, U+0080 and U+000E in strings, and the yen sign in both profiles (it expectedUNASSIGNED_CODEbefore).guest_ces*tests pass three runs in a row.tools/check_conventions.pypasses. The Shift-JIS debt entry was shortened below the 1000-character limit.tools/pr_overlap.pylists the same code-page PRs as the earlier CES changes (#8923, #9912, #9210) and #6044.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)GuestCes.cpp(merge order only); #10722, #10739, #10751 edit the same lines too (merge order only)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T12:24:36Z.
Review: APPROVED
Reviewed the new encoding delta at head
567b164839, stacked on open #10185. The alias mapping and EUC-JP/Shift-JIS C1/BOM handling match the supplied firmware 13.60 measurements. The full-UCS-2 encoder hash sweeps, focused prefix/error checks, and full two-byte Shift-JIS decode sweep give useful regression coverage. Local C++20 syntax checks for the changed implementation and tests, conventions, and diff check pass. Product build jobs are skipped by the current path policy; I could not run the focused executable locally because full CMake configuration stops at the missing SDL2 development package. The declared dependency on #10185 is consistent with the branch stack.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T13:59:13Z.
Review: APPROVED
Re-review of exact current head
556b195d5966ee61e2a97d77aa242def53962a3b. The implementation/test/debt diff against current main is unchanged by the merge-main refresh. The checklist records #10185 as a prerequisite, following the agreed #10183/#10184 -> #10185 -> #10186 -> #10056 order. Exact-head conventions andgit diff --checkpass; GCC C++20-Wall -Wextra -Werror -fsyntax-onlyon the CES export passes. Hosted eligibility, conventions, labels and report pass; product build/test jobs are skipped by path policy. The author reports the CES test matrix on the earlier identical source; I did not run full CMake tests here. Approving this exact head.