From cdf19e63769842fa3669f4b60ca21865bd154b43 Mon Sep 17 00:00:00 2001 From: athrxx Date: Mon, 13 Jun 2022 20:04:51 +0200 Subject: [PATCH] COMMON: fix CP950 encoding regression (I somehow managed to mess up the CP950 encoder with some wrong copy/pasting in b5079ca ) --- common/str-enc.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/common/str-enc.cpp b/common/str-enc.cpp index 2d98005884d..5ff9bb8f8a9 100644 --- a/common/str-enc.cpp +++ b/common/str-enc.cpp @@ -551,18 +551,16 @@ void String::encodeWindows950(const U32String &src, bool transliterate) { if (!windows950ReverseConversionTable && windows950ConversionTable) { uint16 *rt = new uint16[0x10000](); - for (uint lowidx = 0; lowidx < 0xb2; lowidx++) { + for (uint lowidx = 0; lowidx < 157; lowidx++) { uint8 low = 0; - if (lowidx < 0x1a) - low = 0x41 + lowidx; - else if (lowidx < 0x1a * 2) - low = 0x61 + lowidx - 0x1a; + if (lowidx < 0x3f) + low = 0x40 + lowidx; else - low = 0x81 + lowidx - 0x1a * 2; + low = 0xa1 + lowidx - 0x3f; - for (uint highidx = 0; highidx < 0x7e; highidx++) { - uint8 high = highidx + 0x81; - uint16 unicode = windows949ConversionTable[highidx * 0xb2 + lowidx]; + for (uint highidx = 0; highidx < 89; highidx++) { + uint8 high = highidx + 0xa1; + uint16 unicode = windows950ConversionTable[highidx * 157 + lowidx]; rt[unicode] = (high << 8) | low; }