Repository navigation
feat(gametext): decode UTF-8 in plain-text .str files - #3676
dogefly233 wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
ChangesUTF-8 text conversion
Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Feature Possibly related PRs
Suggested labels: Suggested reviewers: Merge Risk:
|
[Medium impact] The PR appears safe to merge; both previous findings are fixed and no new actionable issues remain.
|
781859c to
e9acf8d
Compare
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..strfiles still parse and display identically.