[Ttssh2-commit] [7463] UTF32ToMBCP()からUTF32ToCP932()を呼び出すようにした

scmno****@osdn***** scmno****@osdn*****
2019年 3月 10日 (日) 02:32:55 JST


Revision: 7463
          http://sourceforge.jp/projects/ttssh2/scm/svn/commits/7463
Author:   zmatsuo
Date:     2019-03-10 02:32:55 +0900 (Sun, 10 Mar 2019)
Log Message:
-----------
UTF32ToMBCP()からUTF32ToCP932()を呼び出すようにした

Modified Paths:
--------------
    trunk/teraterm/common/codeconv.cpp

-------------- next part --------------
Modified: trunk/teraterm/common/codeconv.cpp
===================================================================
--- trunk/teraterm/common/codeconv.cpp	2019-03-09 17:32:42 UTC (rev 7462)
+++ trunk/teraterm/common/codeconv.cpp	2019-03-09 17:32:55 UTC (rev 7463)
@@ -558,18 +558,22 @@
 
 size_t UTF32ToMBCP(unsigned int u32, int code_page, char *mb_ptr, size_t mb_len)
 {
-	wchar_t u16_str[2];
-	size_t u16_len;
-	u16_len = UTF32ToUTF16(u32, u16_str, 2);
-	if (u16_len == 0) {
-		return 0;
+	if (code_page == 932) {
+		return UTF32ToCP932(u32, mb_ptr, mb_len);
+	} else {
+		wchar_t u16_str[2];
+		size_t u16_len;
+		u16_len = UTF32ToUTF16(u32, u16_str, 2);
+		if (u16_len == 0) {
+			return 0;
+		}
+		mb_len = WideCharToMultiByte(code_page, 0, u16_str, u16_len, mb_ptr, mb_len, NULL, NULL);
+		if (u32 != '?' && mb_len == 1 && mb_ptr[0] == '?') {
+			// \x95ϊ\xB7\x82ł\xAB\x82Ȃ\xA9\x82\xC1\x82\xBD\x82Ƃ\xAB\x81A\x96߂\xE8\x92l=1, \x95\xB6\x8E\x9A[0]='?' \x82\xF0\x95Ԃ\xB5\x82Ă\xAD\x82\xE9
+			mb_len = 0;
+		}
+		return mb_len;
 	}
-	mb_len = WideCharToMultiByte(code_page, 0, u16_str, u16_len, mb_ptr, mb_len, NULL, NULL);
-	if (mb_len == 1 && mb_ptr[0] == '?' && u32 != '?') {
-		// \x95ϊ\xB7\x82ł\xAB\x82Ȃ\xA9\x82\xC1\x82\xBD\x82Ƃ\xAB\x81A\x96߂\xE8\x92l=1, \x95\xB6\x8E\x9A[0]='?' \x82\xF0\x95Ԃ\xB5\x82Ă\xAD\x82\xE9
-		mb_len = 0;
-	}
-	return mb_len;
 }
 
 /**


Ttssh2-commit メーリングリストの案内