You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
refactor(unichar): Make unichar UTF-16 on every platform and remove the UTF-32 path - #3732
OmniBlade asked in #3187 for unichar to match ICU's UChar, so that it is UTF-16 on every platform and the UTF-32 path in utf8.cpp can go. This is the first part of that follow-up (reply).
Windows keeps wchar_t, which is 16-bit there, so VC6, L"" literals and the Win32 W APIs are unchanged.
deps_icu_linked (the Windows tests against vcpkg ICU) defines UCHAR_TYPE=wchar_t, so UChar is unichar wherever ICU is linked. utf8.cpp now passes unichar* to ICU without casts, so a type mismatch no longer compiles.
cmake/icu.cmake now requires ICU 59, the first version where UChar is char16_t in C++.
utf8.cpp loses the UTF-32 converters, the UTF8_WCHAR_IS_UTF16 switch and its #error. The tests lose their UTF-32 branches and ReplacesWideValuesBeyondUnicode, which cannot exist with a 16-bit unichar.
Off Windows, L"" literals and the wcs*/swprintf calls no longer match unichar. The game does not build there today. The next PRs add a literal macro (L on Windows, u elsewhere), unichar overloads of the wcs* functions built on stringex.h, and a swprintf replacement that keeps the MSVC %s/%hs meaning.
Evidence
utf8_test.cpp on Linux (WSL Ubuntu, g++ 13, ICU 74, unichar = char16_t): 18/18 pass, no warnings with -Wall -Wextra. Before this PR, that build took the UTF-32 path.
…he UTF-32 path
unichar is now char16_t outside Windows, which matches ICU's UChar, so
utf8.cpp no longer converts through UTF-32 there. Windows keeps wchar_t,
and deps_icu_linked defines UCHAR_TYPE=wchar_t so UChar matches it too.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
No actionable comments were generated in the recent review.
Walkthrough
unichar now represents UTF-16 code units on every platform. Linked-ICU conversions use unichar directly, ICU package lookup requires version 59 or newer, and the tests use surrogate pairs and UTF-16 truncation expectations.
Changes
UTF-16 ICU conversion alignment
Layer / File(s)
Summary
Unify the UTF-16 representation and ICU setup Dependencies/Precompiled/Precompiled/unichar.h, Dependencies/ICU/ICU/utf8.h, Dependencies/ICU/CMakeLists.txt, cmake/icu.cmake
unichar is wchar_t on Windows and char16_t elsewhere. The linked ICU target defines UCHAR_TYPE=wchar_t, and package lookup requires ICU 59 or newer.
Use direct ICU conversions and UTF-16 test expectations Dependencies/ICU/ICU/utf8.cpp, Tests/Google/Dependencies/ICU/utf8_test.cpp
Linked-ICU conversions pass unichar directly to ICU, replacing the separate UTF-32 path. Surrogate-pair truncation handling applies unconditionally. Tests use surrogate pairs and remove platform-specific UTF-32 expectations.
Issue 3593: The proposed RTL text path uses ICU UTF-16 functions, and this change aligns non-Windows unichar with ICU’s UChar.
Possibly related PRs
TheSuperHackers/GeneralsGameCode#3187: This PR continues the ICU-based UTF-8 conversion work by aligning unichar with ICU’s UTF-16 representation and removing the UTF-32 conversion path.
Suggested reviewers: bobtista, xezon
Merge Risk: Minimal · up to 07431
This change makes unichar a UTF-16 code unit on every platform and removes the UTF-32 conversion path. Linked ICU now passes unichar directly to its conversion functions, and the ICU lookup requires version 59 or newer. No merge-blocking risk is identified.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title states the main change: unichar becomes UTF-16 on every platform and the UTF-32 path is removed. The changeset matches this. The title uses the conventional refactor(scope) prefix and is 83 …
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Description check
The description states the goal of making unichar UTF-16 on every platform and removing the UTF-32 path from utf8.cpp. It names the affected files and symbols (unichar.h, deps_icu_linked, cmake/icu.cm…
Full details: Title check
Explanation
The title states the main change: unichar becomes UTF-16 on every platform and the UTF-32 path is removed. The changeset matches this. The title uses the conventional refactor(scope) prefix and is 83 characters long, which is slightly long but still clear.
Full details: Description check
Explanation
The description states the goal of making unichar UTF-16 on every platform and removing the UTF-32 path from utf8.cpp. It names the affected files and symbols (unichar.h, deps_icu_linked, cmake/icu.cmake, utf8.cpp, utf8_test.cpp). It also gives a diff, test evidence, and the follow-up plan. It matches the changeset, so the check passes.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: c6e81144-bd7c-46e0-9dcb-de4351047d0e
Commits
Reviewing files that changed from the base of the PR and between 7a3adc8 and 074313a.
Files selected for processing: 1
cmake/icu.cmake
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: a55c6327-baf2-4b21-8672-1b64734a22a2
Commits
Reviewing files that changed from the base of the PR and between 9afbe5c and 7a3adc8.
Files selected for processing: 5
Dependencies/ICU/CMakeLists.txt
Dependencies/ICU/ICU/utf8.cpp
Dependencies/ICU/ICU/utf8.h
Dependencies/Precompiled/Precompiled/unichar.h
Tests/Google/Dependencies/ICU/utf8_test.cpp
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
OmniBlade asked in #3187 for
unicharto match ICU'sUChar, so that it is UTF-16 on every platform and the UTF-32 path inutf8.cppcan go. This is the first part of that follow-up (reply).wchar_t, which is 16-bit there, so VC6,L""literals and the Win32WAPIs are unchanged.deps_icu_linked(the Windows tests against vcpkg ICU) definesUCHAR_TYPE=wchar_t, soUCharisunicharwherever ICU is linked.utf8.cppnow passesunichar*to ICU without casts, so a type mismatch no longer compiles.cmake/icu.cmakenow requires ICU 59, the first version whereUCharischar16_tin C++.utf8.cpploses the UTF-32 converters, theUTF8_WCHAR_IS_UTF16switch and its#error. The tests lose their UTF-32 branches andReplacesWideValuesBeyondUnicode, which cannot exist with a 16-bitunichar.Off Windows,
L""literals and thewcs*/swprintfcalls no longer matchunichar. The game does not build there today. The next PRs add a literal macro (Lon Windows,uelsewhere),unicharoverloads of thewcs*functions built onstringex.h, and aswprintfreplacement that keeps the MSVC%s/%hsmeaning.Evidence
utf8_test.cppon Linux (WSL Ubuntu, g++ 13, ICU 74,unichar=char16_t): 18/18 pass, no warnings with-Wall -Wextra. Before this PR, that build took the UTF-32 path.icu_linked_googletest(Windows, vcpkg ICU 78.3,UChar=wchar_t): 18/18 pass.g_googletestandz_googletest(IcuLoader): 270/270 each.utf8.cppagainst main: 0 changed functions in ClangCLdeps_icu, ClangCLdeps_icu_linkedand VC6deps_icu.AI Assistance:
Claude Opus 5.5 was used to assist implementation and testing