From 744a042e773ae26289f1cc91fd3d51152d3d779d Mon Sep 17 00:00:00 2001 From: tomo Date: Sat, 21 Jul 2001 03:41:08 +0000 Subject: [PATCH] (decode_builtin_char): Check Big5 code range which can be mapped to `chinese-big5-1' and `chinese-big5-2'. --- src/mule-charset.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/mule-charset.c b/src/mule-charset.c index b3c7765..bd56719 100644 --- a/src/mule-charset.c +++ b/src/mule-charset.c @@ -2172,20 +2172,27 @@ decode_builtin_char (Lisp_Object charset, int code_point) { int c1 = code_point >> 8; int c2 = code_point & 0xFF; - unsigned int I - = (c1 - 0xA1) * BIG5_SAME_ROW - + c2 - (c2 < 0x7F ? 0x40 : 0x62); + unsigned int I; - if (c1 < 0xC9) + if ( ( (0xA1 <= c1) && (c1 <= 0xFE) ) + && + ( ((0x40 <= c2) && (c2 <= 0x7E)) || + ((0xA1 <= c2) && (c2 <= 0xFE)) ) ) { - charset = Vcharset_chinese_big5_1; - } - else - { - charset = Vcharset_chinese_big5_2; - I -= (BIG5_SAME_ROW) * (0xC9 - 0xA1); + I = (c1 - 0xA1) * BIG5_SAME_ROW + + c2 - (c2 < 0x7F ? 0x40 : 0x62); + + if (c1 < 0xC9) + { + charset = Vcharset_chinese_big5_1; + } + else + { + charset = Vcharset_chinese_big5_2; + I -= (BIG5_SAME_ROW) * (0xC9 - 0xA1); + } + code_point = ((I / 94 + 33) << 8) | (I % 94 + 33); } - code_point = ((I / 94 + 33) << 8) | (I % 94 + 33); } if ((final = XCHARSET_FINAL (charset)) >= '0') { -- 1.7.10.4