[ttssh2-commit] [9525] 受信文字コード UTF-8m 時、合成済み文字の生成処理を行わない

Back to archive index
scmno****@osdn***** scmno****@osdn*****
2021年 11月 12日 (金) 00:29:56 JST


Revision: 9525
          https://osdn.net/projects/ttssh2/scm/svn/commits/9525
Author:   zmatsuo
Date:     2021-11-12 00:29:56 +0900 (Fri, 12 Nov 2021)
Log Message:
-----------
受信文字コード UTF-8m 時、合成済み文字の生成処理を行わない

- UTF-8m時の受信処理
  - 受信した文字が合成済み文字の基底文字の場合、次の文字を受信するまで処理を保留する
    - 次の受信文字が基底文字と合成可能な結合文字の場合
      - 合成済み文字を生成した後、内部バッファへの書き込み、表示を行う
    - 次の受信文字が結合文字ではない場合
      - 2文字を各々内部バッファへの書き込み、表示を行う
- UTF-8時の受信処理
  - 合成済み文字に変換せずに内部バッファにそのまま入力
- 内部バッファは合成済みでなくても入力を受け付ける
- 表示が遅れることもない
- UTF-8mの処理をなくしてUTF-8時と同じにする

ticket #15826

Ticket Links:
------------
    https://osdn.net/projects/ttssh2/tracker/detail/15826

Modified Paths:
--------------
    trunk/teraterm/teraterm/unicode.cpp
    trunk/teraterm/teraterm/unicode.h
    trunk/teraterm/teraterm/vtterm.c

-------------- next part --------------
Modified: trunk/teraterm/teraterm/unicode.cpp
===================================================================
--- trunk/teraterm/teraterm/unicode.cpp	2021-11-11 15:29:47 UTC (rev 9524)
+++ trunk/teraterm/teraterm/unicode.cpp	2021-11-11 15:29:56 UTC (rev 9525)
@@ -195,7 +195,7 @@
 //
 #include "uni_combining.map"
 
-unsigned short UnicodeGetPrecomposedChar(int start_index, unsigned short first_code, unsigned short code)
+static unsigned short UnicodeGetPrecomposedChar(int start_index, unsigned short first_code, unsigned short code)
 {
 	const combining_map_t *table = mapCombiningToPrecomposed;
 	int tmax = _countof(mapCombiningToPrecomposed);
@@ -216,7 +216,7 @@
 	return (result);
 }
 
-int UnicodeGetIndexOfCombiningFirstCode(unsigned short code)
+static int UnicodeGetIndexOfCombiningFirstCode(unsigned short code)
 {
 	const combining_map_t *table = mapCombiningToPrecomposed;
 	int tmax = _countof(mapCombiningToPrecomposed);
@@ -252,6 +252,14 @@
  *	@param[in]	code
  *	@retval		0		\x8C\x8B\x8D\x87\x82ł\xAB\x82Ȃ\xA2
  *	@retval		\x88ȊO	\x8C\x8B\x8D\x87\x82\xB5\x82\xBDUnicode
+ *
+ *		\x97\xE1
+ *			first_code
+ *				U+307B(\x82\xD9)
+ *			code
+ *				U+309A(\x81K)
+ *			retval
+ *				U+307D(\x82\xDB)
  */
 unsigned short UnicodeCombining(unsigned short first_code, unsigned short code)
 {

Modified: trunk/teraterm/teraterm/unicode.h
===================================================================
--- trunk/teraterm/teraterm/unicode.h	2021-11-11 15:29:47 UTC (rev 9524)
+++ trunk/teraterm/teraterm/unicode.h	2021-11-11 15:29:56 UTC (rev 9525)
@@ -30,8 +30,6 @@
 extern "C" {
 #endif
 
-unsigned short UnicodeGetPrecomposedChar(int start_index, unsigned short first_code, unsigned short code);
-int UnicodeGetIndexOfCombiningFirstCode(unsigned short code);
 char UnicodeGetWidthProperty(unsigned long u32);
 int UnicodeIsCombiningCharacter(unsigned long u32);
 int UnicodeIsVariationSelector(unsigned long u32);

Modified: trunk/teraterm/teraterm/vtterm.c
===================================================================
--- trunk/teraterm/teraterm/vtterm.c	2021-11-11 15:29:47 UTC (rev 9524)
+++ trunk/teraterm/teraterm/vtterm.c	2021-11-11 15:29:56 UTC (rev 9525)
@@ -6129,16 +6129,12 @@
 // UTF-8\x82Ŏ\xF3\x90M\x83f\x81[\x83^\x82\xF0\x8F\x88\x97\x9D\x82\xB7\x82\xE9
 // returns TRUE if b is processed
 //  (actually allways returns TRUE)
-static BOOL ParseFirstUTF8(BYTE b, int proc_combining)
+static BOOL ParseFirstUTF8(BYTE b)
 {
 	static BYTE buf[4];
 	static int count = 0;
-	static int can_combining = 0;
-	static unsigned int first_code;
-	static int first_code_index;
 
 	unsigned int code;
-	unsigned short cset;
 
 	if (ts.FallbackToCP932 && Fallbacked) {
 		return ParseFirstJP(b);
@@ -6148,11 +6144,6 @@
 		// 1\x83o\x83C\x83g\x96ڂ\xA8\x82\xE6\x82\xD12\x83o\x83C\x83g\x96ڂ\xAAASCII\x82̏ꍇ\x82́A\x82\xB7\x82ׂ\xC4ASCII\x8Fo\x97͂Ƃ\xB7\x82\xE9\x81B
 		// 1\x83o\x83C\x83g\x96ڂ\xAAC1\x90\xA7\x8C䕶\x8E\x9A(0x80-0x9f)\x82̏ꍇ\x82\xE0\x93\xAF\x97l\x81B
 		if (count == 0 || count == 1) {
-			if (proc_combining == 1 && can_combining == 1) {
-				PutU32(first_code);
-				can_combining = 0;
-			}
-
 			if (count == 1) {
 				ParseASCII(buf[0]);
 			}
@@ -6171,11 +6162,6 @@
 	if ((buf[0] & 0xe0) == 0xc0) {
 		if ((buf[1] & 0xc0) == 0x80) {
 
-			if (proc_combining == 1 && can_combining == 1) {
-				PutU32(first_code);
-				can_combining = 0;
-			}
-
 			code = ((buf[0] & 0x1f) << 6);
 			code |= ((buf[1] & 0x3f));
 
@@ -6206,42 +6192,6 @@
 		code |= ((buf[1] & 0x3f) << 6);
 		code |= ((buf[2] & 0x3f));
 
-		if (proc_combining == 1) {
-			if (can_combining == 0) {
-				first_code_index = UnicodeGetIndexOfCombiningFirstCode(code);
-				if (first_code_index != -1) {
-					can_combining = 1;
-					first_code = code;
-					count = 0;
-					return (TRUE);
-				}
-			} else {
-				can_combining = 0;
-				cset = UnicodeGetPrecomposedChar(first_code_index, first_code, code);
-				if (cset != 0) { // success
-					code = cset;
-
-				} else { // error
-					// 2\x82‚߂̕\xB6\x8E\x9A\x82\xAA\x94\xBC\x91\xF7\x93_\x82\xCC1\x95\xB6\x8E\x9A\x96ڂɑ\x8A\x93\x96\x82\xB7\x82\xE9\x8Fꍇ\x82́A\x8Dēx\x8C\x9F\x8D\xF5\x82𑱂\xAF\x82\xE9\x81B(2005.10.15 yutaka)
-					first_code_index = UnicodeGetIndexOfCombiningFirstCode(code);
-					if (first_code_index != -1) {
-						// 1\x82‚߂̕\xB6\x8E\x9A\x82͂\xBB\x82̂܂܏o\x97͂\xB7\x82\xE9
-						PutU32(first_code);
-
-						can_combining = 1;
-						first_code = code;
-						count = 0;
-						return (TRUE);
-					}
-
-					PutU32(first_code);
-					PutU32(code);
-					count = 0;
-					return (TRUE);
-				}
-			}
-		}
-
 		PutU32(code);
 
 skip:
@@ -6292,18 +6242,18 @@
 {
 	switch (ts.Language) {
 	  case IdUtf8:
-		ParseFirstUTF8(b, ts.KanjiCode == IdUTF8m);
+		  ParseFirstUTF8(b);
 		return;
 
 	  case IdJapanese:
 		switch (ts.KanjiCode) {
 		  case IdUTF8:
-			if (ParseFirstUTF8(b, 0)) {
+			  if (ParseFirstUTF8(b)) {
 				return;
 			}
 			break;
 		  case IdUTF8m:
-			if (ParseFirstUTF8(b, 1)) {
+			  if (ParseFirstUTF8(b)) {
 				return;
 			}
 			break;
@@ -6317,12 +6267,12 @@
 	  case IdKorean:
 		switch (ts.KanjiCode) {
 		  case IdUTF8:
-			if (ParseFirstUTF8(b, 0)) {
+			if (ParseFirstUTF8(b)) {
 				return;
 			}
 			break;
 		  case IdUTF8m:
-			if (ParseFirstUTF8(b, 1)) {
+			if (ParseFirstUTF8(b)) {
 				return;
 			}
 			break;
@@ -6336,7 +6286,7 @@
 	  case IdRussian:
 		switch (ts.KanjiCode) {
 		case IdUTF8:
-			if (ParseFirstUTF8(b, 0)) {
+			if (ParseFirstUTF8(b)) {
 				return;
 			}
 			break;
@@ -6350,7 +6300,7 @@
 	case IdChinese:
 		switch (ts.KanjiCode) {
 		case IdUTF8:
-			if (ParseFirstUTF8(b, 0)) {
+			if (ParseFirstUTF8(b)) {
 				return;
 			}
 			break;


ttssh2-commit メーリングリストの案内
Back to archive index