[Ttssh2-commit] [7971] 各種文字コードの受信処理

Back to archive index
scmno****@osdn***** scmno****@osdn*****
2019年 8月 15日 (木) 23:05:30 JST


Revision: 7971
          https://osdn.net/projects/ttssh2/scm/svn/commits/7971
Author:   zmatsuo
Date:     2019-08-15 23:05:29 +0900 (Thu, 15 Aug 2019)
Log Message:
-----------
各種文字コードの受信処理

Modified Paths:
--------------
    branches/unicode_buf/teraterm/teraterm/teraterm.cpp
    branches/unicode_buf/teraterm/teraterm/vtterm.c

-------------- next part --------------
Modified: branches/unicode_buf/teraterm/teraterm/teraterm.cpp
===================================================================
--- branches/unicode_buf/teraterm/teraterm/teraterm.cpp	2019-08-15 14:05:18 UTC (rev 7970)
+++ branches/unicode_buf/teraterm/teraterm/teraterm.cpp	2019-08-15 14:05:29 UTC (rev 7971)
@@ -326,6 +326,7 @@
 			}
 			_CrtCheckMemory();
 		}
+		_CrtCheckMemory();
 	}
 	delete m_pMainWnd;
 	m_pMainWnd = NULL;

Modified: branches/unicode_buf/teraterm/teraterm/vtterm.c
===================================================================
--- branches/unicode_buf/teraterm/teraterm/vtterm.c	2019-08-15 14:05:18 UTC (rev 7970)
+++ branches/unicode_buf/teraterm/teraterm/vtterm.c	2019-08-15 14:05:29 UTC (rev 7971)
@@ -214,6 +214,11 @@
 
 static _locale_t CLocale = NULL;
 
+#if UNICODE_INTERNAL_BUFF
+// \x93\xE0\x95\x94\x83R\x81[\x83h unicode\x94\xC5
+static void UnicodeToCP932(unsigned int code);
+#endif
+
 void ClearParams()
 {
 	ICount = 0;
@@ -665,7 +670,23 @@
 		CharAttrTmp.Attr |= CharAttr.Attr;
 
 #if UNICODE_INTERNAL_BUFF
-	if (ts.Language == IdRussian) {
+	if (ts.Language == IdJapanese) {
+		unsigned long u32;
+		switch (ts.KanjiCode) {
+//		case IdJIS:
+//			b = JIS2SJIS(b);
+		case IdSJIS:
+			u32 = MBCP_UTF32(b, 932);
+			BuffPutUnicode(u32, CharAttrTmp, InsertMode);
+			break;
+		case IdUTF8:
+			BuffPutUnicode(b, CharAttrTmp, InsertMode);
+			break;
+		default:
+			BuffPutUnicode(b, CharAttrTmp, InsertMode);
+			break;
+		}
+	} else if (ts.Language == IdRussian) {
 		BYTE c = RussConv(ts.RussHost, IdWindows, b);
 		unsigned long u32 = MBCP_UTF32(c, 1251);
 		BuffPutUnicode(u32, CharAttrTmp, InsertMode);
@@ -796,7 +817,7 @@
 		// codepage\x88ꗗ
 		// https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-ucoderef/28fefe92-d66c-4b03-90a9-97b473223d43
 		unsigned long u32 = 0;
-		if (ts.Language == IdKorean) {
+		if (ts.Language == IdKorean && ts.CodePage == 51949) {
 			unsigned char buf[2];
 			int ret;
 			wchar_t wchar;
@@ -805,13 +826,14 @@
 			ret = MultiByteToWideChar(51949, MB_ERR_INVALID_CHARS, (char *)buf, 2, &wchar, 1);
 			u32 = wchar;
 			BuffPutUnicode(u32, CharAttrTmp, InsertMode);
-		} else if (ts.Language == IdJapanese) {
+		} else if (ts.Language == IdJapanese && ts.CodePage == 932) {
 			// \x82\xB1\x82\xB1\x82ɗ\x88\x82\xBD\x8E\x9E\x93_\x82\xC5CP932\x82ɂȂ\xC1\x82Ă\xA2\x82\xE9
 			//} else if (ts.KanjiCode == IdSJIS || ts.KanjiCode == IdEUC || ts.KanjiCode == IdJIS) {
 			u32 = CP932ToUTF32(Kanji);
 			BuffPutUnicode(u32, CharAttrTmp, InsertMode);
 		} else {
-			assert(FALSE);
+			u32 = MBCP_UTF32(Kanji, ts.CodePage);
+			BuffPutUnicode(u32, CharAttrTmp, InsertMode);
 		}
 	}
 #else
@@ -5157,10 +5179,28 @@
 	}
 }
 
-BOOL CheckKanji(BYTE b)
+/**
+ *	dbcs\x82\xCC1byte\x96ڃ`\x83F\x83b\x83N?
+ */
+static BOOL CheckKanji(BYTE b)
 {
 	BOOL Check;
 
+#if UNICODE_INTERNAL_BUFF
+	if (ts.CodePage != 932) {
+		// TODO \x82\xBF\x82\xE1\x82\xF1\x82ƃ`\x83F\x83b\x83N\x82\xB7\x82\xE9
+		// IsDBCSLeadByteEx() \x82\xAA\x91Ó\x96?
+		if (ts.CodePage == 936) {
+			// chs
+			return ((0x81 <= b) && (b <= 0xfe));
+		}
+		if (ts.CodePage == 950) {
+			// cht
+			return ((0x88 <= b) && (b <= 0xfe));
+		}
+
+	}
+#endif
 	if (ts.Language!=IdJapanese)
 		return FALSE;
 
@@ -5216,7 +5256,7 @@
 	return Check;
 }
 
-BOOL ParseFirstJP(BYTE b)
+static BOOL ParseFirstJP(BYTE b)
 // returns TRUE if b is processed
 //  (actually allways returns TRUE)
 {
@@ -5277,6 +5317,14 @@
 		if ((Gn[Glr[0]] == IdKatakana) || EUCkanaIn) {
 			b = b | 0x80;
 			EUCkanaIn = FALSE;
+#if UNICODE_INTERNAL_BUFF
+			{
+				// b\x82\xCDsjis\x82̔\xBC\x8Ap\x83J\x83^\x83J\x83i
+				unsigned long u32 = CP932ToUTF32(b);
+				UnicodeToCP932(u32);
+			}
+			return TRUE;
+#endif
 		}
 		PutChar(b);
 	}
@@ -5335,9 +5383,15 @@
 		    (ts.KanjiCode==IdSJIS) ||
 		    (ts.KanjiCode==IdJIS) &&
 		    (ts.JIS7Katakana==0) &&
-		    ((ts.TermFlag & TF_FIXEDJIS)!=0))
+		    ((ts.TermFlag & TF_FIXEDJIS)!=0)) {
+#if UNICODE_INTERNAL_BUFF
+			// b\x82\xCDsjis\x82̔\xBC\x8Ap\x83J\x83^\x83J\x83i
+			unsigned long u32 = CP932ToUTF32(b);
+			UnicodeToCP932(u32);
+#else
 			PutChar(b);	// katakana
-		else {
+#endif
+		} else {
 			if (Gn[Glr[1]] == IdASCII) {
 				b = b & 0x7f;
 			}
@@ -5553,7 +5607,6 @@
 		else
 			LineEnd = CursorRightM;
 
-		BOOL half_width = (UnicodeGetWidthProperty(code) == 'H') ? TRUE : FALSE;
 
 		if (Wrap) {
 			CarriageReturn(FALSE);
@@ -5564,6 +5617,7 @@
 		else if (CursorX > LineEnd - 1) {
 			if (AutoWrapMode) {
 				if (ts.EnableContinuedLineCopy) {
+					BOOL half_width = (UnicodeGetWidthProperty(code) == 'H') ? TRUE : FALSE;
 					CharAttrTmp.Attr |= AttrLineContinued;
 					if (half_width == FALSE && CursorX == LineEnd) {
 						// full width\x8Fo\x97͂\xAA\x94\xBC\x95\xAA\x8Fo\x97͂ɂȂ\xE7\x82Ȃ\xA2\x82悤\x82\xC90x20\x82\xF0\x8Fo\x97\xCD


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