feat(libSceCesCs): add the ISO-2022-JP profiles, context and string conversions #10428
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10428"
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-24T00:03:17Z.
What
Twenty-one libSceCesCs exports for ISO-2022-JP that still threw now work: the profile initialisers
sceCesUcsProfileInitIso2022JpRfc1468,Cp50221andCp50222,sceCesIso2022UcsContextInitandInitCopy, and the sixteen string conversions between ISO-2022-JP and UTF-8, UCS-2, UTF-16 and UTF-32 in both directions with their length-only forms (sceCesUtf8StrToIso2022Str,sceCesUtf8StrGetIso2022Len,sceCesIso2022StrToUtf8Str,sceCesIso2022StrGetUtf8Lenand the same for the other three encodings).The behaviour is measured on a PS5. I ran homebrew payloads that load the console's
libSceCesCs.sprxand callsceCesUtf32StrToIso2022Stron every BMP scalar andsceCesIso2022StrToUtf32Stron every designation followed by every byte and every 94×94 pair, for each profile, plus 46 multi-character strings per profile through the UTF-8 forms. Earlier heads followed RFC 1468 and Microsoft's descriptions; the console differs from them in several places, and this head matches it on every one of those inputs (result, both lengths and output):ESC ( Bselects it too (0x5Cis ¥,0x7Eoverline); it uses the strict JIS X 0208 table of #10718, so U+005C goes out asESC $ B 21 40and U+007E is unassigned. Half-width katakana answer0x805C0024. A string does not have to end in ASCII.ESC ( Jas ASCII, and use CP932's table (NEC row 13 and the IBM rows 89-92 included) with the JIS forms as extra encodings (U+00A5 →21 6F, U+2014 →21 3D). CP50221 writes katakana asESC ( I; CP50222 uses SO/SI, follows SI withESC ( B, and does not acceptESC ( I.ESC $ ( D, like any other designation it does not know, is accepted and makes every following character answer0x805C0015.0x805C0024; U+001B answers0x805C0011at the end of the input and0x805C0015before more; a designation at the very end of the input answers0x805C0011. U+FEFF writes nothing. On an error both lengths report the progress so far.The type database has none of these exports, so the signatures follow the MBCS string family by analogy, which the names mirror one for one. The UTF-16 and UCS-2 forms share the converters and were not measured separately.
sceCesIso2022JpUcsProfileSetSbcskeeps throwing; it belongs with the other single-byte-set selectors.Tested
940424456b(verify run on my fork; Ubuntu 24.04, GCC, Release, lavapipe): everyguest_ces*test passes; its failures (pr_overlap_encoding) aremain's on that runner. macOS (Apple clang 21, x86-64): everyguest_ces*source passes against thisExport.cpp, and a harness built from it matches the console dump for every input above.guest_ces_iso2022(new, both link variants): on RFC 1468,あencodes toESC $ B 24 22 ESC ( B,Aあ¥B\ntoA ESC $ B 24 22 ESC ( J 5C B ESC ( B \n,‾~toESC ( J 7E ESC ( B 7E, each decodes back and theGetLenforms match;ESC $ @decodes as JIS X 0208; a string ending in JIS X 0208 or in JIS X 0201 Roman is refused (also by the length-only form) while the same text followed byESC ( Bdecodes; ESC, SO and SI are unassigned on encode (on all three profiles); anESC ( I, SO orESC $ ( Dsequence is refused, as are a truncated escape or pair, an unknown escape, a byte above0x7F, an empty row-9 cell and a bad trail; half-width katakana and a supplementary-plane character are unassigned on encode; the destination size and the null-buffer and null-context errors are checked, and a copied context converts. On 50221,カgivesESC ( I 36 ESC ( B,カあgivesESC ( I 36 ESC $ B 24 22 ESC ( B, SO is refused,ESC ( I 60is unassigned, a string ending in JIS X 0208 decodes, andESC $ ( D 30 21decodes to the character the EUC-JP SS3 decoder gives for8F B0 A1and encodes back toESC $ ( D 30 21 ESC ( B, which RFC 1468 refuses. On 50222,カgivesSO 36 SI,カあカAgivesSO 36 SI ESC $ B 24 22 ESC ( B SO 36 SI A, and bothESC ( Iand SO decode, a string ending shifted out included. (Earlier heads encoded the three reserved controls verbatim and accepted any final state, then a final Roman designation, on RFC 1468; @MarcZX10 flagged each.) UCS-2, UTF-16 and UTF-32 round-tripAあin both directions with matching length-only forms.guest_ces,guest_ces_mbc,guest_ces_unicode,guest_ces_japanese,guest_ces_chinese,guest_ces_wideandguest_ces_dbcsstill pass.guest_ces_iso2022andguest_ces_iso2022_modulepass, andguest_ces,guest_ces_mbc,guest_ces_unicode,guest_ces_japanese,guest_ces_chinese,guest_ces_wideandguest_ces_dbcspass, each binary run directly with its exit status checked.guest_ces*tests, the two new ones included; the Linux full build (Ubuntu 24.04, GCC, Release, lavapipe) compiles everything and passes everyguest_ces*test, its two failures beingagc_driver_queued_index_read_orderandagc_driver_sgpr_pattern_fill_keys, whichmainfails on that runner.check_conventions.pypasses.pr_overlap.pyreports #9175 on the removedPendingExports.cpplines (it removes eight others nearby), #10056 and #10214 on the debt file, and #9912 as an uncompared sharer of the same files; none implements an ISO-2022 export.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 MarcZX10 on 2026-10-24T00:17:55Z.
Review: CHANGES_REQUESTED
I found a round-trip correctness blocker in the ASCII/control branch. It emits every scalar below 0x80 verbatim, including U+001B, U+000E and U+000F. Those bytes are reserved by the codec: ESC begins a designation, while SO/SI change the CP50222 shift state; RFC 1468 explicitly excludes ESC, SO and SI from single-byte characters (https://www.rfc-editor.org/rfc/rfc1468, formal syntax). Consequently the encoder reports success for values its decoder treats as escape/shift syntax or rejects. For example, encoding U+000E on RFC 1468 emits 0E, which the same profile's decoder rejects; on CP50222 it changes state without producing U+000E. Please return UNASSIGNED_CODE for these unrepresentable control scalars and add round-trip/error tests for all three across profiles.
There is a second RFC-profile mismatch: fromIso2022 returns success regardless of the final designation state, and the tests explicitly accept a JIS X 0208 string ending without a return to ASCII. RFC 1468 requires text to end in ASCII. Please enforce that for the RFC 1468 profile (or provide a separate documented permissive mode if that is intended) and cover the non-ASCII-terminal case.
The changed Export.cpp and GuestCesIso2022.cpp pass C++20 syntax checks; diff-check and conventions pass. The current hosted run passes conventions, eligibility, intake, labels and report; product jobs are skipped for these paths. The PR description reports Linux and Windows focused builds/tests, but those reported runs do not cover the cases above.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T00:23:31Z.
Review: CHANGES_REQUESTED
Thanks for addressing both findings from my first review. The reserved-control encoder cases and a final JIS X 0208 state are now rejected and have regression coverage.
I found one remaining RFC 1468 mismatch in the updated decoder.
fromIso2022accepts a finalIso2022Set::Romanstate for the RFC 1468 profile (state.set != Ascii && state.set != Romanis the rejection condition), andCheckRfc1468explicitly expectsESC ( Jat end of input to decode successfully. RFC 1468 says “the text must end in ASCII” (section 2) and its formal syntax annotates the final sequence “must end in ASCII” (https://www.rfc-editor.org/rfc/rfc1468, lines 131–137 and 153–155). The same RFC distinguishes ASCII (ESC ( B) from the Roman set (ESC ( J) and says Roman replaces backslash and tilde (lines 99–122). Please require the final ASCII designation for the RFC 1468 profile and change the Roman-terminal test to expectCES_ERROR_INVALID_ENCODE, or document authoritative console-specific behavior if this profile intentionally diverges from RFC 1468.I ran the current-main conventions check and
git diff --check; both pass. I attempted a focused local CMake configuration, but it stops before generating targets because SDL2 development package configuration is unavailable. I therefore did not claim a local product test run. The PR author reports container tests; the targeted test case above currently asserts the behavior in question rather than catching it.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T00:33:27Z.
Review: APPROVED
Reviewed the current head
9080ba49ff50bdc2b47c12ca24e3be73bd4accd6and the complete ISO-2022 conversion diff. The RFC 1468 end-state handling now requires ASCII, reserved ESC/SO/SI are rejected as character data, and the focused tests cover the designation, malformed-input, and length-only cases. The author reports Linux and Windows test runs on this head; I also ran the local syntax-only compile,git diff --check, and current-main conventions check successfully. Hosted conventions, eligibility, labels, and report pass; product build jobs are skipped by workflow policy. The shared debt/build files are sequencing conflicts only; I found no overlapping ISO-2022 implementation.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T08:22:03Z.
Review: APPROVED
Re-reviewed exact head
2b4bbf8036bed5254ad370187344695878a6b923against currentmain4c7d275bef89d309313d16bc2bc05d37a1b50be2.The ISO-2022 implementation, tests and public-header usage are unchanged from the measured feature head
9e7f470109; the subsequent changes are the #10430 merge/rebase, debt-count adjustment and restored SPIR-V submodule pointers. Both declared dependencies, #10718 and #10722, are merged. TheTestedsection reports the fresh relinker-only build and 391/391 tests on the current head; the Linux guest/header suites were reported on the unchanged feature source/test revision.Checks run:
51eb9b0dd7a3c16c6b2f1716c0db00e57e12fe6d).python3 tools/check_conventions.py --base upstream/main --head refs/review/upstream-10428: passed.mainsince this branch's base.I did not rerun the guest suites locally. No blocking finding remains.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T10:28:09Z.
Review: CHANGES_REQUESTED
Follow-up — changes requested
A new review note identified one observable behavior that the current debt entry does not cover. In the exact head
2b4bbf8036bed5254ad370187344695878a6b923,sceCesIso2022UcsContextInitrejects a null context but stores a null profile and returns success; the analogous MBCS initializer rejects both null pointers. The PR's console measurements cover the ISO-2022 conversion forms, not this initializer result.Please either add a direct console measurement and make the implementation match it, or state in the ISO-2022-JP debt entry that the null-profile initializer result is unmeasured. This is a narrow behavior/evidence gap; the rest of the implementation and current-head checks remain as reviewed. I did not rerun tests because no source change is requested unless measurement shows the current behavior is wrong.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T17:30:15Z.
Review: DISMISSED
Reviewed — changes requested
The new firmware-module result confirms that the current initializer returns success for a null profile instead of the measured invalid-parameter result.
What I ran
Head
2b4bbf8036bed5254ad370187344695878a6b923; basebb04a4f1ea0175e9e4f149f0359a764d62ff3296.git merge-treeproduced a clean preview tree (c29b90d4ede24fc7c4585b389fe913a3358648f0); no merge was attempted. Environment: Debian Linux x86_64, Python 3.11.2.Results
git diff --checkLocal check output
Negative control
0x805C0001and zeroes its first 256 bytesFindings
Blocking
sceCesIso2022UcsContextInitchecks onlycontext, copiesprofileinto the first pointer-sized bytes, and returns success. With a null profile it therefore returns0, whereas the new firmware-module measurement reports0x805C0001and zeroes bytes+0x00through+0xFFfor a non-null context. Please implement that observed behavior and add a regression that checks both the return value and all 256 cleared bytes. Ensure the test context buffer is at least 256 bytes. The null-context case should continue returning0x805C0001without touching memory.Non-blocking
None found in the reviewed follow-up scope.
Sources
Not verified
To get this to a good state
Make the initializer and test match the reported return value and 256-byte clearing behavior. I will rerun these same commands and the focused test on the new head.