mirror of
https://github.com/1dot13/source.git
synced 2026-07-29 13:52:17 +02:00
spell the Chinese percent sign as an escape instead of raw bytes
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%<A3><A5>%%" 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 %<fullwidth percent> 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.
This commit is contained in:
committed by
majcosta
parent
b147e47856
commit
8495af4b00
@@ -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) );
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user