feat(libSceIcu): implement bidi, charset detection, normalization and simple case exports over ICU #16605

Merged
justdoston merged 12 commits from upstream-pr/16605 into main 2026-11-11 05:26:38 +00:00
justdoston commented 2026-11-07 08:45:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by justdoston on 2026-11-07T08:45:35Z.


What

Implements 38 libSceIcu exports that no other open PR touches by forwarding them to ICU 78.1, built from the 3rdparty/icu submodule that #13578 adds. This PR is stacked on #13578. Because #13578 currently conflicts with main, the branch includes one merge commit (9e7b8d4553) that merges main into it. That merge keeps main's u_charDigitValue/u_digit (CharacterDigits.cpp) instead of #13578's duplicate wrappers, removes the 47 stubs #13578 implements under their current names, and recounts the debt entries. This PR's own change is the last commit.

Area Exports
Bidirectional text (Bidi.cpp) ubidi_open, ubidi_close, ubidi_setPara, ubidi_getParaLevel, ubidi_countRuns, ubidi_getVisualRun, ubidi_getLogicalRun, ubidi_getBaseDirection, ubidi_reorderVisual, ubidi_setClassCallback, ubidi_getClass (11)
Charset detection (CharsetDetection.cpp) ucsdet_open, ucsdet_close, ucsdet_setText, ucsdet_detectAll, ucsdet_getName, ucsdet_getConfidence, ucsdet_enableInputFilter (7)
Normalization (Normalization.cpp) unorm2_getNFCInstance, unorm2_getNFDInstance, unorm2_getInstance (nfc only), unorm2_normalize, unorm2_normalizeSecondAndAppend, unorm2_append, unorm2_getDecomposition, unorm2_getRawDecomposition, unorm2_composePair, unorm2_getCombiningClass, unorm2_isNormalized, unorm2_quickCheck, unorm2_spanQuickCheckYes, unorm2_hasBoundaryBefore, unorm2_hasBoundaryAfter, unorm2_isInert (16)
Code points (CodePoints.cpp) u_tolower, u_toupper, u_totitle, ublock_getCode (4)
  • The prototypes of all 38 are identical in the ICU 68.2 headers (the 3.20 module's version) and in ICU 78.1.
  • Null pointers that ICU dereferences throw std::invalid_argument. Every other input, including failing statuses and invalid arguments ICU reports through UErrorCode, goes to ICU unchanged.
  • A guest ubidi_setClassCallback callback runs through a host adapter with the guest ABI. The previous guest callback and context are reported back, and the adapter state is released in ubidi_close.
  • Paths that need ICU data files still throw: NFKC/NFKD/NFKC_Casefold instances and unorm2_getInstance for other names or packages. unorm2_openFiltered and unorm2_close throw because guest uset_* sets are not ICU objects. All of these are recorded in docs/dev/debt/libSceIcu.md.
  • cmake/Icu.cmake:
    • Adds ubidi.cpp, ubidiln.cpp, ubidiwrt.cpp, ustr_cnv.cpp and ustrfmt.cpp to icu_common.
    • Moves uenum.cpp out of the Windows-only block.
    • Adds the converter sources that CharsetMatch::getUChars in csmatch.cpp links against. That function is not exported; the converters are built so the library resolves every symbol on every platform.
    • Adds a new icu_i18n target with the charset detector sources.
  • u_tolower, u_toupper, u_totitle, ublock_getCode and six unorm2_* were bare-named declarations in Export.cpp. They now use the _nid_postfix suffix, which the NID ignores.

Tested

Linux (Ubuntu, GCC), not the full project build. A CMake harness includes the repository's cmake/Icu.cmake and builds the four new sources as a shared library linked with --no-undefined, with ASan and UBSan:

  • No undefined symbols.
  • Exactly the 38 *_nid_postfix functions are exported, with no ICU symbols.
  • The new tests guest_icu_bidi, guest_icu_charset_detection, guest_icu_normalization and guest_icu_code_points pass with leak detection on. Their expected values come from Unicode data: bidi runs and levels, NFC/NFD of U+00E9, U+1E08 and Hangul, combining classes, UTF-8/UTF-16 BOM detection at confidence 100, simple case mappings and block codes.
  • Changing one expected value made the test abort, so the checks do run.

tools/check_conventions.py and test_public_headers.py --audit-only pass. Windows and macOS were not built locally.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: #13578
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5199981252 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16605). Originally posted by [justdoston](https://github.com/justdoston) on 2026-11-07T08:45:35Z. --- ### What Implements 38 libSceIcu exports that no other open PR touches by forwarding them to ICU 78.1, built from the `3rdparty/icu` submodule that #13578 adds. This PR is stacked on #13578. Because #13578 currently conflicts with `main`, the branch includes one merge commit (`9e7b8d4553`) that merges `main` into it. That merge keeps main's `u_charDigitValue`/`u_digit` (`CharacterDigits.cpp`) instead of #13578's duplicate wrappers, removes the 47 stubs #13578 implements under their current names, and recounts the debt entries. This PR's own change is the last commit. | Area | Exports | |---|---| | Bidirectional text (`Bidi.cpp`) | `ubidi_open`, `ubidi_close`, `ubidi_setPara`, `ubidi_getParaLevel`, `ubidi_countRuns`, `ubidi_getVisualRun`, `ubidi_getLogicalRun`, `ubidi_getBaseDirection`, `ubidi_reorderVisual`, `ubidi_setClassCallback`, `ubidi_getClass` (11) | | Charset detection (`CharsetDetection.cpp`) | `ucsdet_open`, `ucsdet_close`, `ucsdet_setText`, `ucsdet_detectAll`, `ucsdet_getName`, `ucsdet_getConfidence`, `ucsdet_enableInputFilter` (7) | | Normalization (`Normalization.cpp`) | `unorm2_getNFCInstance`, `unorm2_getNFDInstance`, `unorm2_getInstance` (`nfc` only), `unorm2_normalize`, `unorm2_normalizeSecondAndAppend`, `unorm2_append`, `unorm2_getDecomposition`, `unorm2_getRawDecomposition`, `unorm2_composePair`, `unorm2_getCombiningClass`, `unorm2_isNormalized`, `unorm2_quickCheck`, `unorm2_spanQuickCheckYes`, `unorm2_hasBoundaryBefore`, `unorm2_hasBoundaryAfter`, `unorm2_isInert` (16) | | Code points (`CodePoints.cpp`) | `u_tolower`, `u_toupper`, `u_totitle`, `ublock_getCode` (4) | - The prototypes of all 38 are identical in the ICU 68.2 headers (the 3.20 module's version) and in ICU 78.1. - Null pointers that ICU dereferences throw `std::invalid_argument`. Every other input, including failing statuses and invalid arguments ICU reports through `UErrorCode`, goes to ICU unchanged. - A guest `ubidi_setClassCallback` callback runs through a host adapter with the guest ABI. The previous guest callback and context are reported back, and the adapter state is released in `ubidi_close`. - Paths that need ICU data files still throw: NFKC/NFKD/NFKC_Casefold instances and `unorm2_getInstance` for other names or packages. `unorm2_openFiltered` and `unorm2_close` throw because guest `uset_*` sets are not ICU objects. All of these are recorded in `docs/dev/debt/libSceIcu.md`. - `cmake/Icu.cmake`: - Adds `ubidi.cpp`, `ubidiln.cpp`, `ubidiwrt.cpp`, `ustr_cnv.cpp` and `ustrfmt.cpp` to `icu_common`. - Moves `uenum.cpp` out of the Windows-only block. - Adds the converter sources that `CharsetMatch::getUChars` in `csmatch.cpp` links against. That function is not exported; the converters are built so the library resolves every symbol on every platform. - Adds a new `icu_i18n` target with the charset detector sources. - `u_tolower`, `u_toupper`, `u_totitle`, `ublock_getCode` and six `unorm2_*` were bare-named declarations in `Export.cpp`. They now use the `_nid_postfix` suffix, which the NID ignores. ### Tested Linux (Ubuntu, GCC), not the full project build. A CMake harness includes the repository's `cmake/Icu.cmake` and builds the four new sources as a shared library linked with `--no-undefined`, with ASan and UBSan: - No undefined symbols. - Exactly the 38 `*_nid_postfix` functions are exported, with no ICU symbols. - The new tests `guest_icu_bidi`, `guest_icu_charset_detection`, `guest_icu_normalization` and `guest_icu_code_points` pass with leak detection on. Their expected values come from Unicode data: bidi runs and levels, NFC/NFD of U+00E9, U+1E08 and Hangul, combining classes, UTF-8/UTF-16 BOM detection at confidence 100, simple case mappings and block codes. - Changing one expected value made the test abort, so the checks do run. `tools/check_conventions.py` and `test_public_headers.py --audit-only` pass. Windows and macOS were not built locally. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: #13578 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!16605
No description provided.