From 8495af4b004ac1e5547975e6f8b00a3a66cae736 Mon Sep 17 00:00:00 2001 From: "Marco Antonio J. Costa" Date: Wed, 22 Jul 2026 14:13:36 -0300 Subject: [PATCH] spell the Chinese percent sign as an escape instead of raw bytes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Four string literals carry the bytes A3 A5, which is GBK for U+FF05, the fullwidth percent sign. All four sit in g_lang == i18n::Lang::zh branches added by "Chinese specific update (by zww from tbs)", and each has an ASCII sibling in the else branch using an ordinary percent. clang-cl decodes source as UTF-8, where A3 is not a valid lead byte: error: illegal character encoding in string literal A raw high byte in a literal means whatever the compiler's source charset says it means, so this text has never been portable. Asking the cl we build with what it makes of L"%d%%%" gives a 7-character string whose fourth character is 163 -- it reads the bytes as Latin-1 and produces two characters, £ and Â¥, not the one the author wrote. The same probe on L"%d%ï¼…%%" gives 6 characters with U+FF05 in that position. So the Chinese text has been rendering as garbage in any build not made on a CP936 machine, this one included. Writing the character as ï¼… says exactly which character is meant regardless of the compiler's charset, and restores what the branch was written to display. The format grammar is untouched. In each of these strings the character is preceded by a percent, making % an unknown conversion specification that prints the character following it -- the same trick the else branches spell as %%. Where a string is formatted twice, once into a buffer and again as the format argument of mprintf, the doubling in the sibling literal (%%%%) is what survives two passes; that pairing is unchanged. Both files are now pure ASCII: python3 -c "print(sum(1 for b in open(F,'rb').read() if b>0x7f))" The parse sweep drops from 5 error sites in 3 files to 1 in 1 -- the inline assembly in sgp/vobject_blitters.cpp is all that is left. --- Strategic/Map Screen Interface Map.cpp | 4 ++-- Tactical/Interface Items.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Strategic/Map Screen Interface Map.cpp b/Strategic/Map Screen Interface Map.cpp index 74196c451..b0fd4bcbd 100644 --- a/Strategic/Map Screen Interface Map.cpp +++ b/Strategic/Map Screen Interface Map.cpp @@ -1196,7 +1196,7 @@ DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"Map Screen1"); if( gTownLoyalty[ bTown ].fStarted && gfTownUsesLoyalty[ bTown ]) { if ( g_lang == i18n::Lang::zh ) { - swprintf( sStringA, L"%d%£¥%% %s", gTownLoyalty[ bTown ].ubRating, gsLoyalString[ 0 ]); + swprintf( sStringA, L"%d%\uFF05%% %s", gTownLoyalty[ bTown ].ubRating, gsLoyalString[ 0 ]); } else { swprintf( sStringA, L"%d%%%% %s", gTownLoyalty[ bTown ].ubRating, gsLoyalString[ 0 ]); } @@ -4866,7 +4866,7 @@ void BlitMineText( INT16 sMapX, INT16 sMapY ) if (GetMaxPeriodicRemovalFromMine(ubMineIndex) > 0) { if ( g_lang == i18n::Lang::zh ) { - swprintf( wSubString, L" (%d%£¥%%)", (PredictDailyIncomeFromAMine(ubMineIndex, TRUE) * 100 ) / GetMaxDailyRemovalFromMine(ubMineIndex) ); + swprintf( wSubString, L" (%d%\uFF05%%)", (PredictDailyIncomeFromAMine(ubMineIndex, TRUE) * 100 ) / GetMaxDailyRemovalFromMine(ubMineIndex) ); } else { swprintf( wSubString, L" (%d%%%%)", (PredictDailyIncomeFromAMine(ubMineIndex, TRUE) * 100 ) / GetMaxDailyRemovalFromMine(ubMineIndex) ); } diff --git a/Tactical/Interface Items.cpp b/Tactical/Interface Items.cpp index 6ec55465b..3ea5214a3 100644 --- a/Tactical/Interface Items.cpp +++ b/Tactical/Interface Items.cpp @@ -12407,7 +12407,7 @@ void GetHelpTextForItem( STR16 pzStr, OBJECTTYPE *pObject, SOLDIERTYPE *pSoldier if ( gGameExternalOptions.fAdvRepairSystem && sThreshold < 100 ) { if( g_lang == i18n::Lang::zh ) { - swprintf( pStr, L"%s [%d%£¥(%d%£¥)]\n%s %d\n%s %d\n%s %d (%d)\n%s (%d) %s\n%s %1.1f %s", + swprintf( pStr, L"%s [%d%\uFF05(%d%\uFF05)]\n%s %d\n%s %d\n%s %d (%d)\n%s (%d) %s\n%s %1.1f %s", ItemNames[ usItem ], sValue, sThreshold, @@ -12449,7 +12449,7 @@ void GetHelpTextForItem( STR16 pzStr, OBJECTTYPE *pObject, SOLDIERTYPE *pSoldier else { if( g_lang == i18n::Lang::zh ) { - swprintf( pStr, L"%s [%d%£¥]\n%s %d\n%s %d\n%s %d (%d)\n%s (%d) %s\n%s %1.1f %s", + swprintf( pStr, L"%s [%d%\uFF05]\n%s %d\n%s %d\n%s %d (%d)\n%s (%d) %s\n%s %1.1f %s", ItemNames[ usItem ], sValue, gWeaponStatsDesc[ 9 ], //Accuracy String