Revision: 7430 http://sourceforge.jp/projects/ttssh2/scm/svn/commits/7430 Author: zmatsuo Date: 2019-02-17 23:43:54 +0900 (Sun, 17 Feb 2019) Log Message: ----------- utf8の4byteの受信に対応 Modified Paths: -------------- trunk/teraterm/teraterm/vtterm.c -------------- next part -------------- Modified: trunk/teraterm/teraterm/vtterm.c =================================================================== --- trunk/teraterm/teraterm/vtterm.c 2019-02-15 12:21:06 UTC (rev 7429) +++ trunk/teraterm/teraterm/vtterm.c 2019-02-17 14:43:54 UTC (rev 7430) @@ -5519,11 +5519,11 @@ } // UTF-8\x82Ŏ\xF3\x90M\x83f\x81[\x83^\x82\xF0\x8F\x88\x97\x9D\x82\xB7\x82\xE9 -BOOL ParseFirstUTF8(BYTE b, int proc_combining) // returns TRUE if b is processed // (actually allways returns TRUE) +static BOOL ParseFirstUTF8(BYTE b, int proc_combining) { - static BYTE buf[3]; + static BYTE buf[4]; static int count = 0; static int can_combining = 0; static unsigned int first_code; @@ -5586,7 +5586,7 @@ return TRUE; } - if ((buf[0] & 0xe0) == 0xe0 && + if ((buf[0] & 0xf0) == 0xe0 && (buf[1] & 0xc0) == 0x80 && (buf[2] & 0xc0) == 0x80) { // 3\x83o\x83C\x83g\x83R\x81[\x83h\x82̏ꍇ @@ -5643,12 +5643,31 @@ skip: count = 0; + } + + if (count < 4) { + return TRUE; + } + + if ((buf[0] & 0xf1) == 0xf0 && + (buf[1] & 0xc0) == 0x80 && + (buf[2] & 0xc0) == 0x80 && + (buf[2] & 0xc0) == 0x80) + { // 4\x83o\x83C\x83g\x83R\x81[\x83h\x82̏ꍇ + code = ((buf[0] & 0x07) << 18); + code |= ((buf[1] & 0x3f) << 12); + code |= ((buf[2] & 0x3f) << 6); + code |= (buf[3] & 0x3f); + + UnicodeToCP932(code); + count = 0; + return TRUE; } else { ParseASCII(buf[0]); ParseASCII(buf[1]); ParseASCII(buf[2]); + ParseASCII(buf[3]); count = 0; - } return TRUE;