Repository navigation
feat(icu4c): Add ICU4C support to UTF8 string operations - #3187
Conversation
PR Summary by QodoAdd ICU4C-backed UTF-8 conversions and link ICU into the engine
AI Description
Diagram
High-Level Assessment
Files changed (13)
|
Code Review by Qodo
1.
|
|
/agentic_review |
|
Code review by qodo was updated up to the latest commit 0240a44 |
|
@greptileai review this |
[Medium impact] The reviewed changes appear safe to merge.
|
0240a44 to
c27b37a
Compare
|
To use Codex here, create a Codex account and connect to github. |
|
@codex review this |
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
OmniBlade
left a comment
There was a problem hiding this comment.
There is a lot of needless complexity here IMO, why are we worrying about using ICU on VC6 at all and dynamically loading it? Alternate codepaths for wchar_t as UTF-16 and UTF-32 also bothers me, its a more invasive change, but putting the "wide" types behind an ifdef and removing wchar_t use from the code base allows for simpler conversion functions that are easier to understand and maintain once the pain of getting rid of wchar_t has been taken care of.
I'd prefer to see this broken down into two PRs, one to move all use of wchar_t behind a typedef and then a second to use ICU exclusively for none windows platforms and make the typedef UChar on those platforms for consistent use of UTF-8 and UTF-16 only.
|
I would prefer to have icu supported on windows so that we can get proper bidirectional string support without needing another library like FriBidi in the future. I'd be happy to separate this into two prs. |
xezon
left a comment
There was a problem hiding this comment.
Does VC6 use ICU or not? It is not clear from the code. Implementation looks confusing.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the
Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. WalkthroughThe build adds a dedicated ChangesICU UTF-8 Integration
Estimated code review effort: 4 (Complex) | ~45 minutes Change: Feature Sequence Diagram(s)sequenceDiagram
participant GameMain
participant UnicodeString_translate
participant ICU_utf8
participant IcuLoader
GameMain->>IcuLoader: create IcuScope
UnicodeString_translate->>ICU_utf8: request UTF-8 to wide-character conversion
ICU_utf8->>IcuLoader: query ICU functions when dynamic loading is enabled
IcuLoader-->>ICU_utf8: return resolved conversion functions
ICU_utf8-->>UnicodeString_translate: return converted length or conversion result
Pre-merge checks:
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 0d0a0605-d996-4f8e-a869-b3b6770009eb
📥 Commits
Reviewing files that changed from the base of the PR and between 0b9cf8b and 6777d4227a9ac7e56b8e34fa4f86f4741b7480b8.
📒 Files selected for processing (18)
CMakeLists.txtCore/GameEngine/CMakeLists.txtCore/GameEngine/Source/Common/System/AsciiString.cppCore/GameEngine/Source/Common/System/UnicodeString.cppCore/GameEngine/Source/GameNetwork/GameInfo.cppCore/GameEngine/Source/GameNetwork/GameSpy/Thread/ThreadUtils.cppCore/Libraries/Source/WWVegas/WWLib/CMakeLists.txtCore/Libraries/Source/WWVegas/WWLib/utf8.cppCore/Libraries/Source/WWVegas/WWLib/utf8.hDependencies/ICU/CMakeLists.txtDependencies/ICU/ICU/IcuLoader.cppDependencies/ICU/ICU/IcuLoader.hDependencies/ICU/ICU/IcuSupport.hDependencies/ICU/ICU/utf8.cppDependencies/ICU/ICU/utf8.hDependencies/ICU/README.mdcmake/icu.cmakevcpkg.json
💤 Files with no reviewable changes (2)
- Core/Libraries/Source/WWVegas/WWLib/utf8.cpp
- Core/Libraries/Source/WWVegas/WWLib/utf8.h
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
VC6 does use ICU through a fallback icu.dll load |
Wide Char PR is up #3321 |
cc8321a to
c1ee4e6
Compare
9fed3c7 to
8766fdf
Compare
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8766fdf011
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Waiting on review. Feel free to fork off of my branch on my repo and work on that if you want to. |
| { | ||
| clear(); | ||
| } | ||
| else if (dstLen >= static_cast<size_t>(MAX_LEN)) |
There was a problem hiding this comment.
The same condition needs to be in UnicodeString then, no?
There was a problem hiding this comment.
I don't think so. UTF-8 never decodes to have more wide units than it has bytes: 1 to 4 bytes become 1 or 2 UTF-16 units. The fallback for invalid UTF-8 maps bytes 1:1. So the result is never longer than the source AsciiString, which is already within MAX_LEN, and UnicodeString::ensureUniqueBufferOfSize still asserts on it. Only the wide to UTF-8 direction can grow, by up to 3 bytes per unit.
…SuperHackers#3187) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…kers#3187) Co-Authored-By: Claude Opus 5.5 <[email protected]>
1e061e1 to
52db156
Compare
|
@OmarAglan heads-up: I force-pushed |
I postponed my RTL work, until you fully merge your text system work |
…SuperHackers#3187) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…kers#3187) Co-Authored-By: Claude Opus 5.5 <[email protected]>
52db156 to
4ee6068
Compare
…n utf8 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…orts Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
… length Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Given the merge of the unichar change, what needs to happen now is that unichar is made UChar for when ICU is linked, but that requires a sweep of everything that is |
That sweep touches about 127 files with VC6 cannot compile |
|
That sounds acceptable, my concern is that temp workarounds have a bad habit of sticking around so as long as there is commitment to clean up that is fine. |
bobtista
left a comment
There was a problem hiding this comment.
Looks good, and it's been a long time comin - non-blocking question: icu is now a baseline vcpkg dependency, so game-only builds such as win32-vcpkg will build or fetch it even though only the test target links ICU. Is it going to be used more? Or should we make it test only or something?
Windows games load the OS icu.dll at runtime, so only the IcuLoader comparison tests link ICU from vcpkg there. Non-Windows builds still get ICU as a base dependency. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Good point. On Windows the game loads the OS icu.dll at runtime, so only the tests link ICU from vcpkg. ICU is now a vcpkg dependency only on non-Windows, and on Windows a |
Thanks. I'll open the |
…afbe5c): ICU4C for UTF-8 string operations The UTF-8 conversions move from WWLib to Dependencies/ICU. On Windows the game loads the system's icu.dll at run time and falls back to the Win32 CP_UTF8 conversion when the DLL or its exports are missing; no new build dependency (only test builds look for ICU through vcpkg). The game engine's link list takes deps_icu beside our d3d9. Checked before merging: the merged tree configured and built in a scratch worktree (z_generals Release, 0 errors); this commit's tree is that build's source.
…erHackers#3421-TheSuperHackers#3424 and ICU4C (TheSuperHackers#3187) main took TheSuperHackers/GeneralsGameCode up to 9afbe5c on 29/11 as six merges. go-merge already had the first nine of those commits through ronin-dx9 (fddffd3), so this brings the other five: - bobtista's renderer series (TheSuperHackers#3421-TheSuperHackers#3424): shader and material state, texture binding, buffers and draw calls and render-target binding go through Renderer, which calls the same DX8Wrapper functions as before. Our DX9 lines keep their DX8Wrapper calls; the water mirror keeps its own depth buffer through Renderer::Set_Render_Target_With_Z. - ICU4C for UTF-8 strings (TheSuperHackers#3187): the game loads the system's icu.dll at run time, with the Win32 CP_UTF8 fallback; no new package on Windows. Conflicts: vcpkg.json keeps GO's dependencies and its openal-audio feature beside upstream's non-Windows icu entry and tests feature; cmake/config-vcpkg.cmake keeps GO's include beside upstream's tests-only ICU block; render2d.cpp keeps go-merge's file header (upstream's text). render2d's calls inside the GENONLINE guards keep their DX8Wrapper names, the same calls. Checked before merging: the merged tree configured and built in a scratch worktree (z_generals Release, win32-vcpkg-local, 0 errors); this commit's tree is that build's source.
Right-to-left text (#2, #3593) needs ICU for bidirectional ordering and Arabic shaping, and the engine has no ICU dependency yet. This PR adds ICU and moves the existing UTF-8 conversion onto it, so the RTL work has a dependency to build on. OmarAglan's RTL work is based on this branch.
Summary
Two commits, so the edit to
utf8.cppshows as a diff and runs against the same tests:git mvof the hand-written converter; the only change in the file is its include. Adds the full test suite, run against the old implementation.Later review commits on top: tab indentation in
IcuLoader, anicu.dllnext to the game that lacks the needed exports now falls through to the System32 one,windows.hmoved out ofIcuLoader.h,Wide_To_Utf8null-terminates when it rejects a length overINT_MAX, anddeps_icu_linkedlinksICU::datalikedeps_icu.IcuLoaderloadsicu.dllfrom the game folder, then System32, and resolvesu_strFromUTF8andu_strToUTF8WithSubCP_UTF8when the DLL or exports are missingicu_linked_googletestlinks ICU from vcpkg and runs the sameutf8_test.cpputf8.cppconverts in full and cuts on a boundary itself.AsciiString,UnicodeString,GameInfo,ThreadUtils) only change their include fromWWLib/utf8.htoICU/utf8.h.AsciiString::translatenow clears text whose UTF-8 form exceedsMAX_LEN, with aDEBUG_CRASH. UTF-8 can need up to three bytes per wide character.UnicodeString::translateneeds no such check, because UTF-8 never decodes to more wide units than it has bytes.vcpkg.jsonnow pullsicuon all platforms, so Windows vcpkg test builds can link it. The Windows game still usesIcuLoader.icuuc.dllrather thanicu.dll, so they use the fallback. Before Vista, Win32CP_UTF8encodes and accepts lone surrogates instead of replacing or rejecting them.Evidence
Tests/Google/Dependencies/ICU/utf8_test.cpphas 18 tests: encoding-length boundaries, supplementary codepoints, embedded nulls, source length, lone surrogates, UTF-32 values beyond U+10FFFF, 23 malformed inputs (overlong, encoded surrogates, beyond U+10FFFF, truncated, 5 and 6 byte forms), measuring without a destination, exact fit without a terminator, truncation on codepoint boundaries, andUtf8_Truncate_Len.z_googletest,g_googletest)IcuLoaderwith the OSicu.dll(z_googletest,g_googletest)icu_linked_googletest)IcuLoaderwith the OSicu.dll(z_googletest,g_googletest)AsciiStringTest.cppaddstranslateround trips and the legacy CP1252 byte fallback inUnicodeString::translate. TheMAX_LENlimit has no test yet.Disassembly of the review commits (ClangCL and VC6 Release, against the previous head):
Wide_To_Utf8only changes register allocation for the new terminator path,Utf8_To_Wideis unchanged in Release, andIcuLoaderload/loadModulechange as intended. Call targets match and there is no float arithmetic.icu_linked_googletestwas not re-run on the current head.AI Disclosure
GPT 6 Astra and Claude Opus 5.5 were used to review this pr and implement changes