feat(libSceCesCs): add the GB18030-2000 and GB18030-2005 profiles #9210
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9210"
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:19:00Z.
What
Implements
sceCesUcsProfileInitGb18030_2000andsceCesUcsProfileInitGb18030_2005. simonbronk said on #8993 that GB 18030 is not on his list and that I can go ahead after the stack, so this branch carries his stack and only the top commit is new.union* (SceCesUcsProfileSheet* sheet), likesceCesUcsProfileInitGbkCp936, and they tag the sheet the same way.gb18030Rangesof ucnvmbcs.c at 39f9a868. I picked the revision before ICU-8427 on purpose. That ticket (icu-data 91850aec, ICU 6206b737) copied the 20050xA8BCmapping into the 2000 file because ICU wanted an "updated GB18030 (2000 version)" as its built-in converter. The earlier revision is GB 18030-2000 as published, and it matches Python'sgb18030codec on every sequence. The current 2000 file differs from it only in U+1E3F and U+E7C7.gb18030Rangesof ucnvmbcs.cpp at release-74-2 (unchanged since ICU-8427).0xA2E3U+20AC and0xA8BFU+01F9) are stored as runs: 111 for 2000, 118 for 2005.0x90308130-0xE3329A35= U+10000-U+10FFFF. There is no per-character table for them.Gb18030.hppis generated by a script I did not commit. Before writing it, the script checks the runs against the ucm mapping on every two-byte cell, every four-byte sequence up to past0xE3329A35and every scalar.0xA8BC(U+E7C7 -> U+1E3F) and0x8135F437(U+1E3F -> U+E7C7);A6D9-A6DF,A6EC,A6ED,A6F3-> U+FE10-U+FE19;FE59,FE61,FE66,FE67,FE6D,FE7E,FE90,FEA0-> U+9FB4-U+9FBB;FE51,FE52,FE53,FE6C,FE76,FE91-> U+20087, U+20089, U+200CC, U+215D7, U+2298F, U+241FE. In the 2005 file the old PUA code points are|1fallbacks, so they still encode to those cells. The four-byte forms of U+FE10-U+FE19, U+9FB4-U+9FBB and the six ideographs still decode to them through ICU's ranges, but those characters encode to the two-byte cells, as ICU does.0x80and0xFFare invalid leads (the0x80euro is GBK only).0x8431A530-0x8F39FE39and everything from0xE3329A36are well formed but unassigned. Errors follow the GBK forms: a bad second, third or fourth byte givesINVALID_ENCODE, a cut sequenceSRC_BUFFER_END, an unassigned oneUNASSIGNED_CODE, and outputs are untouched on failure.isMbcsaccepts both profiles,decodeMbcsandencodeMbcsdispatch them, and thesceCesGbTo*andsceCes*ToGbforms accept them, since they take the same "Gb" profile as GBK andsceCesGbUcsProfileSet4ByteCharRangeonly makes sense for GB 18030. GB 18030 is the first profile that produces supplementary characters, so the MBCS encode buffers grow from 3 to 4 bytes,encodeUtf8writes 4-byte UTF-8, the UTF-16 outputs (the scalar forms,sceCesMbcsStrToUtf16StrandsceCesMbcsStrGetUtf16Len) write surrogate pairs, and the UCS-2 outputs answerUNASSIGNED_CODEfor them assceCesUtf8ToUcs2does. Nothing changes for the existing profiles.sceCesGbUcsProfileSet4ByteCharRange,sceCesGbUcsProfileSetUdaMappingandsceCesGbUcsProfileSetSbcs. I found nothing that says which values they take or what they change. I assume the full ucm mapping is the default they would change, and the debt entry says so.docs/dev/debt/libSceCesCs.mdafter the GBK one, gap first. I also dropped "GB 18030 four-byte forms" from the GBK entry's not-handled list and changed the pending-exports count from 72 to 70.Overlap: #9175 (my
*ToMbcPR on the same stack) and #9107 edit nearby lines inExport.cpp,PendingExports.cppand the debt file, and so does my strict JIS X 0208 profiles PR #9204 on the same stack. None of them implements these exports; whichever lands second needs a small rebase.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_chineseandguest_ces_chinese_moduletake 0.05 s each. I extendedGuestCesChinese.cpp(the GBK and EUC-CN test) so that it checks, for both profiles:8431A530,8F39FE39,E3329A36,FD308130andFE39FE39;80,FF, cut81,81 30and81 30 81, bad second bytes (00,2F,3A,7F,FF), bad third (80,FF,30) and fourth (2F,3A,81) bytes and unassigned sequences, throughsceCesGbToUtf32andsceCesMbcToUcs2, with outputs and lengths untouched;UNASSIGNED_CODE, UTF-8 gives 4 bytes, UTF-16 native,beandlegive surrogate pairs, and short buffers giveDST_BUFFER_ENDwith nothing written; 4-byte UTF-8 and surrogate-pair UTF-16 intosceCes*ToGb; an MBCS context round trip through UTF-8, UTF-16 and the UTF-16 length form, andUNASSIGNED_CODEfromsceCesMbcsStrToUcs2Str.Oracle: the ucm files are the primary oracle. As an independent check I compared both mappings with Python 3.14.8's
gb18030codec on every two-byte cell, every four-byte sequence from81308130to pastE3329A35, and every scalar. Python implements GB 18030-2000, not 2005: it matches the 2000 profile with no differences in either direction, and it differs from the 2005 profile in exactly the 26 decodes and 26 encodes listed above (it keeps0xA8BC= U+E7C7 and the PUA). The 2000 column of the 88 listed sequences was also checked against Python.Negative control: with
Export.cppandPendingExports.cppfromHEAD~1,guest_ces_chineseandguest_ces_chinese_moduleabort withsceCesUcsProfileInitGb18030_2000 not implementedand the other 12 tests pass. With the library restored butGb18030.hppregenerated from the current ICU 2000 file (after ICU-8427), both tests abort too. After restoring everything, all 14 pass.python3 tools/progress.py --module libSceCesCs: 215/287 before, 217/287 after.python3 tools/check_conventions.py --base 15e71dbe11passes. Not tested on a console, on Windows or with a title.Hosted runs on my fork (GitHub runners), this branch
85ced7905and the stack headc020ce893as the base:net_dontwait_blocking_*tests and the intermittentagc_driver_sgpr_pattern_fill_keys, #8708).guest_ces*tests pass (14/14 on the base).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:18Z.
Windows run of 85ced79051 merged onto
main0c6a5bd593(c34236ab75, 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:22Z.
Rebased onto current
main(8b3e39832a): head5f7e0da3bc, same diff.