feat(libSceCesCs): add the strict JIS X 0208 EUC-JP and Shift-JIS profiles #9204
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9204"
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 rooklz on 2026-10-21T15:15:15Z.
What
Implements the four strict JIS X 0208 profile initializers that were still pending in libSceCesCs:
sceCesUcsProfileInitEucJpX0208,sceCesUcsProfileInitEucJpX0208Ss2,sceCesUcsProfileInitEucJpX0208Ss2Ss3andsceCesUcsProfileInitSJis1997X0208. simonbronk said on #8993 that these aren't on his list and I can go ahead, so this branch carries his whole stack and only the top commit is new.union* sceCesUcsProfileInitEucJpX0208(SceCesUcsProfileSheet* sheet), and the same shape for the other three. Like the CP932 and CP51932 initializers, each one writes an 8-byte tag into the caller's sheet and returns the sheet (null gives null). The console's sheet layout is still unknown.X0208is two-byte JIS X 0208 only,X0208Ss2adds the half-width katakana behind SS2 (8E A1-8E DF, U+FF61-U+FF9F), andX0208Ss2Ss3also adds JIS X 0212 behind SS3 through the existingJisX0212.hpp. Bytes below0x80are ASCII, as in the CP51932 profile and in IANA's EUC-JP registration (code set 0 is US-ASCII). In a variant without SS2 or SS3, a0x8Eor0x8Flead answersINVALID_ENCODElike any other byte that can't start a character, and encoding a half-width katakana or a JIS X 0212-only character answersUNASSIGNED_CODE.JisX0208.hppholds (checked cell by cell). JIS0208.TXT is that table without row 13 (NEC) and rows 89-92 (NEC-selected IBM), and seven cells differ:0x2140(U+005C, CP932 U+FF3C),0x2141(U+301C, U+FF5E),0x2142(U+2016, U+2225),0x215D(U+2212, U+FF0D),0x2171(U+00A2, U+FFE0),0x2172(U+00A3, U+FFE1) and0x224C(U+00AC, U+FFE2). So instead of a second 8836-entry header, the strict table is the existing one with those rows dropped and a six-entry change list (the seventh cell is below). My generation script, which isn't committed, checked that the result equals JIS0208.TXT in all 8836 cells. Every strict cell maps to a different code point, so encoding is exact; the strict reverse table is built like the CP932 one.SJis1997X0208uses the same table through the existing Shift-JIS row/cell arithmetic, with0xA1-0xDFas half-width katakana and no IBM extensions. Leads0xF0-0xFCanswerUNASSIGNED_CODE, as CP932's user-defined area does. The double-byte part of SHIFTJIS.TXT is identical to JIS0208.TXT.sceCesMbcTo*accept the new profiles, through the sameisEucJp,isSjisandisMbcschecks.Still throwing, recorded in
docs/dev/debt/libSceCesCs.md. These throwstd::runtime_errorinstead of callingNotImplemented_nid_no_patch, because they sit in the shareddecodeMbcs/encodeMbcspaths andtools/progress.pywould otherwise count all 53 converters that use them as stubs again:0x2140(A1 C0in EUC-JP,81 5Fin Shift-JIS) in all four profiles, and encoding U+FF3C with them. JIS0208.TXT and SHIFTJIS.TXT give U+005C, but glibc 2.39 (EUC-JP,SJIS) and Python 3.14'seuc_jpandshift_jisgive U+FF3C, and in EUC-JP U+005C would collide with the ASCII byte0x5C. The sources disagree and I have no console data, so I kept it throwing rather than pick one.SJis1997X0208, the single bytes0x5Cand0x7E, and encoding U+005C, U+007E, U+00A5 and U+203E. SHIFTJIS.TXT maps the bytes to U+00A5 and U+203E (JIS X 0201 Roman, as do glibc'sSJISand Python'sshift_jis_2004), while CP932 and Python'sshift_jisuse ASCII. SharpProspero doesn't cover this profile. The library also exportssceCesRefersUcsProfileAscii,sceCesRefersUcsProfileJisX0201Roman,sceCesRefersUcsProfileJisX0201RomanTilde0x7eandsceCesSJisUcsProfileSetSbcs, so the single-byte set looks selectable, and none of the sources says which one this profile starts with. #8923 leaves thoseJisX0201*andAsciisingle-byte profiles throwing for the same reason. Every other single byte is the same in all of these sources.Debt: a new "Strict JIS X 0208 profiles" entry in the middle of Unknown function info, and the pending-exports count goes from 76 to 72. Nothing here is a console measurement. No open PR implements these four functions. #9175 and #9107 also change the pending count line and nearby lines in
Export.cpp, so whichever lands second rebases.The CesCs test executables in the variant loop now get
configure_windows_unwind, as the libSceVoice and libSceRtc tests do, becauseguest_ces_japaneseis the first CesCs test that catches an exception thrown inside the library; without it the exception doesn't unwind into the test on MinGW.Tested
Ubuntu 24.04 x86-64 in a Docker container under Rosetta on an Apple M5 Mac, GCC 13.3, Release:
All 14
guest_ces*tests pass;guest_ces_japaneseandguest_ces_japanese_moduletake 0.05 s each. No new warnings in the CesCs sources. I extendedGuestCesJapanese.cpp, which is already registered, so that it checks:A1-FExA1-FE) through each of the three EUC-JP profiles, and every one of the 94 x 94 cells throughSJis1997X0208(bytes fromsceCesJisX0208ToSJisCode). Each assigned cell decodes and encodes back to the same bytes, each unassigned one answersUNASSIGNED_CODEwith the output and length untouched, and0x2140throws with the expected message;0x2140) and an FNV-1a-32 digest of the 8836 decoded values in row order (0 for unassigned cells and0x2140), both computed by my generation script straight from JIS0208.TXT. SHIFTJIS.TXT's double-byte part gives the same count and digest;AD A1,87 40), the NEC-selected IBM rows 89-92 (F9 A1,ED 40,EE FC) and the IBM extensions (FA 40,FC 4B) answerUNASSIGNED_CODEin the strict profiles, while CP932 and CP51932 still decode them; so doF0 40and the empty row 94 (EF FC). U+FF5E, U+2225, U+FF0D, U+FFE0-U+FFE2, U+2460 and U+2170 don't encode, the six JIS forms do (U+301C toA1 C1and81 60), and U+7E8A (CP932 row 89) encodes as JIS X 02128F D4 E3only inX0208Ss2Ss3;X0208Ss2andX0208Ss2Ss3,X0208rejects8E,X0208andX0208Ss2reject8F, and neither of the two without SS3 encodes U+4E02. InX0208Ss2Ss3the whole JIS X 0212 plane is swept: 6067 cells and a digest computed from JIS0212.TXT, each cell encoding back to itself except0x2237, which JIS0212.TXT maps to U+007E and so encodes as ASCII7E;SJis1997X0208: ASCII except5Cand7E, which throw,A1-DFas katakana,80,A0andFD-FFINVALID_ENCODE, leads aloneSRC_BUFFER_END. Encoding U+005C, U+007E, U+00A5, U+203E and U+FF3C throws, and the EUC-JP profiles keep5Cand7Eas ASCII;INVALID_PARAMETER, bad trailsINVALID_ENCODE, cut pairs and triplesSRC_BUFFER_END, a short outputDST_BUFFER_END; plussceCesEucJpToUtf8and MBCS context strings with the new profiles.Oracle cross-check: Python 3.14.8's
euc_jpandshift_jisdecode all 8836 cells exactly as JIS0208.TXT does except0x2140(U+FF3C), and neither decodes a cell JIS0208.TXT leaves empty. glibc 2.39iconvagrees on0x2140being U+FF3C. That one cell is why the test uses the table file as its oracle and not a codec. The generation script also checked thatJisX0208.hppequals CP932.TXT andJisX0212.hppequals JIS0212.TXT cell for cell.Negative control, after committing: with
c020ce893'sExport.cppandPendingExports.cpprestored,guest_ces_japaneseandguest_ces_japanese_moduleabort withsceCesUcsProfileInitEucJpX0208 not implementedand the other 12 pass. With only the row filter changed so that row 92 leaks back into the strict table, both abort at the count and digest check of the first EUC-JP sweep. After restoring, all 14 pass again.python3 tools/progress.py --module libSceCesCs: 211/287 before, 215/287 after, with no function moving back to pending.python3 tools/check_conventions.py --base 15e71dbe11passes. Not tested on a console, on Windows or with a title. I didn't runtools/pr_overlap.py; I checked the open libSceCesCs PRs by hand instead.Hosted runs on my fork (GitHub runners), with the stack head
c020ce893as the base:net_dontwait_blocking_*tests fail on both;agc_driver_sgpr_pattern_fill_keysfailed on the base run only (intermittent, #8708).ab1a43c9c: all 14guest_ces*tests pass. The first Windows run, before theconfigure_windows_unwindline, failedguest_ces_japaneseandguest_ces_japanese_modulewith the 0x2140 exception escaping the test (0xc0000409).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)Imported from boykopovar/AnyPS5. Originally posted by ycbuzi on 2026-10-21T20:49:20Z.
Windows run of ab1a43c9c3 merged onto
main0c6a5bd593(2cc241d933, 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
libSceCesCsand the 14guest_ces*test executables with no errors or warnings.ctest --repeat until-fail:2on the 14 tests these executables register on Windows: all pass on both repeats. The 14 are the baseguest_cesand theguest_ces_*tests and their_modulevariants (dbcs, unicode, japanese, wide, chinese, mbc). Not run: a title.Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-10-22T13:34:17Z.
Rebased onto current
main(8b3e39832a): head6081493184, same diff.