Repository navigation
feat(gametext): decode UTF-8 in plain-text .str files - #3676
dogefly233 wants to merge 1 commit into
Conversation
|
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. Walkthrough
ChangesUTF-8 text conversion
Estimated code review effort: 2 (Simple) | ~10 minutes Change: Feature Possibly related PRs
Suggested reviewers: Merge Risk:
|
[Medium impact] The PR appears safe to merge; no actionable issues remain.
|
781859c to
e9acf8d
Compare
translateCopy now unescapes into a scratch buffer and converts the result with Utf8_To_Wide_Len/Utf8_To_Wide, falling back to the previous 1:1 byte cast when the text is not valid UTF-8, matching UnicodeString::translate.
e9acf8d to
12552c4
Compare
|
@bobtista thanks a lot for the suggestion — I have updated the code exactly as you described. I also built it locally (VS 2022 Build Tools, |


Problem
In release builds the game prefers the plain-text
Data\Generals.strover the compiledgenerals.csf(m_useStringFile = TRUE,g_strFile = "data/Generals.str"). That path is the most convenient one for translators and modders because it is plain text, but its conversion to wide characters,GameTextManager::translateCopy, copies exactly one byte per character:*outbuf++ = *inbuf & 0x00FF;Anything outside Latin-1 therefore cannot survive it. A UTF-8 Chinese
.str, for example, renders asåä°æ...in the UI. This has been worked around for years by a runtime hook shipped as a Miles proxy DLL (mss32.dll); that workaround only works while the engine loads Miles, and it cannot apply to builds or ports that do not.Change
translateCopy; otherwise keep the exact legacy byte copy, so existing ANSI strings keep their current output.WideCharis 16-bit.parseMapStringFilecalls the same function, so map.strfiles benefit as well.Compatibility
ä) is now decoded as UTF-8. That is the intended reading for.strtext, and distinguishing the two would require an explicit encoding setting; I can add one if you prefer.Testing
Data\Generals.strsaved as UTF-8 (Chinese text): menu and label text render correctly. Verified locally, screenshots in the comment above..strfiles still parse and display identically.