feat(libSceIme): implement sceImeFilterText #8036
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8036"
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 ymatrix1 on 2026-10-19T18:19:56Z.
What
Implements
sceImeFilterTextfor every input, following the disassembly oflibSceIme.sprx(firmware 13.60). It validates the arguments and mask, then filters the text by type: ASCII, number, Latin and the mask-driven class walk (Cyrillic, Thai, Greek, Arabic, Vietnamese, Romanian, fullwidth punctuation and two codepage sets). The two codepage checks (helpers at 0x4850 and 0x48f0) are CP932 and GBK/GB18030 membership tests.ImeFilterCodepages.hppis generated from Unicode's public CP932.TXT and CP936.TXT plus the additions listed below; the generator is attached below and the output is byte-identical to the header in this PR.sceImeCheckFilterTextis declared and throws. The debt entry records the source and the unknowns.Additions on top of the public tables (observed by comparing against the real function's accepted units):
Generator: python mkpub.py <dir with CP932.TXT and CP936.TXT> ImeFilterCodepages.hpp
Tested
Differential test against the real function run in an x86-64 emulator (unicorn, with a shim for the AVX instructions): 28,000 random cases over all types, masks, version and variant values, capacities and source lengths, 0 mismatches. A unit test (
GuestImeFilterText) passes when compiled with g++ against the filter logic. The full CMake build and ctest were not run, and nothing was measured on a console.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 github-actions[bot] on 2026-10-19T18:20:35Z.
Progress report (
5f7e302→9a6f7c1)📉 System libraries: 64.19% (-0.01%, +1 implemented, +1 declared functions)
✅ 1 implemented
sceImeFilterText🆕 1 declared as stubs
sceImeCheckFilterTextImported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-19T18:32:03Z.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/libs/prx/libSceIme/CMakeLists.txtImported from boykopovar/AnyPS5. Originally posted by wachi35676 on 2026-10-20T00:16:43Z.
Windows 11, Ryzen 5 9600X, WinLibs GCC 15.2.0 (UCRT), Release,
BUILD_TESTING=ON, full CMake configure. Head2e0d8d7abmerged ontomaineb7500680. The description says the full build and ctest were not run.libSceIme, andguest_ime_filter_textpasses, together withguest_ime_open,guest_ime_dialog,guest_ime_keyboardandguest_ime_parameters.guest_ime_filter_textand the otherguest_ime_*tests pass.Codepage provenance. The debt says the two tables were derived by running the firmware's helpers over all 65536 units, and that "the encodings are not identified". I compared both sets with Python's codec repertoires (I can share the script):
kCodepageABitmap(7,610 units) is exactly Windows-31J/CP932 with U+00A0–U+00FF, U+2014 and U+203E added, and with U+0080–U+009F, the private-use ranges U+E000–U+E757 and U+F8F0–U+F8F3 removed. The set compares equal, with 0 differing units.kCodepageBRanges(28,878 units) is GBK/CP936 (all 21,919 GBK units are in it) plus:Every unit is in GB18030.
So A is a Shift_JIS/CP932 converter and B is a GBK/GB18030 converter. The tables could be generated from the public mapping files (Unicode/WHATWG CP932 and GB18030) with the listed exceptions, instead of shipping 1,024 + 151 entries read out of the firmware module. Either way, the debt can name the encodings.
The filter logic itself (class masks,
DerivedMask,ValidMask) has no source other than the firmware disassembly. shadPS4 only stubssceImeFilterText(ime.cppline 429), and KytyPS5 and SharpProspero have nothing for it, so I could not check it independently.AI-assisted: yes (Claude Code); results above were run on this machine.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-20T05:09:44Z.
@ymatrix1 thanks, the behaviour and the differential test look good. One request about
ImeFilterCodepages.hpp: the codepage bitmaps are extracted from the firmware'slibSceIme.sprx, and we'd rather not ship data copied out of the firmware. Could you regenerate them from a public source instead, for example the Unicode data files and the published codepage mappings, ideally with the small script that builds them, and keep your 28k-case test as the check that the result matches? If the tables come from rules you can describe, generating them in code works too.Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-20T07:59:56Z.
Rebase handoff — rebased onto current
main(3fd1cc393, authorship unchanged). One debt conflict:main's unknown-signature stub list kept, yoursceImeFilterTextentry added.Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release,
BUILD_TESTING=ON, AMD RX 9070 XT / RADV): builds; 1672/1675 — green apart from the three knownmainfailures (#7584 BDA, #7784 guest-memory, tessellation), none from this PR; conventions pass.To pick it up:
Head is
1bf25e1de.Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-20T08:00:34Z.
Correction on the handoff above: my first push was missing your second commit (
2e0d8d7ab, the debt-entry shortening) — the rebase had stopped on it and my push went out mid-rebase. The branch is now complete at0cacac901with both commits:main's unknown-signature stub list kept, yoursceImeFilterTextentry added in its shortened form. Same verification as above (1672/1675, green apart from the three knownmainfailures; conventions pass). Apologies for the churn.Imported from boykopovar/AnyPS5. Originally posted by ymatrix1 on 2026-10-20T09:57:59Z.
@oneandonlydean done.
ImeFilterCodepages.hppis now generated from Unicode's public CP932.TXT and CP936.TXT plus a short list of additions (Latin-1, CJK Extension A and a few other units the firmware also accepts). The generator is in the PR description, and its output is byte-identical to the previous header, so the 28k-case differential test still passes unchanged. The debt entry now names the sources and encodings. Thanks to @wachi35676 for the independent identification of both sets.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-20T10:53:08Z.
Thanks, that answers it. We ran your generator on freshly downloaded CP932.TXT and CP936.TXT and got a header byte-identical to the committed one, and the additions are ranges written in code with a public basis, so this is fine on our side.
#8009 has just merged, and this branch now conflicts with it only in
docs/dev/debt/libSceIme.md(both PRs add entries to the same list). Could you merge or rebase onto current main and keep both sets of entries? We'll run full CI on the new head right after.Optional, not blocking: committing the generator under
tools/would let the header be regenerated later, andsceImeCheckFilterTexthas an unusedparam(the neighbouring exports write(void)param).Imported from boykopovar/AnyPS5. Originally posted by ymatrix1 on 2026-10-20T14:19:31Z.
@oneandonlydean thanks. Merged current
maininto the branch, keeping both sets of debt entries, and added(void)paramtosceImeCheckFilterText. The generator stays in the PR description only; I removed thetools/copy I had briefly added.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-20T14:25:01Z.
Thanks. Keeping the generator in the PR description is fine. There's no need to add it under
tools/for this PR. Full CI onc0af90213is next.