Develop and Download Open Source Software

Browse Subversion Repository

Diff of /trunk/teraterm/teraterm/vtterm.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 9499 by zmatsuo, Sat Oct 23 16:09:57 2021 UTC revision 9525 by zmatsuo, Thu Nov 11 15:29:56 2021 UTC
# Line 6129  static void ParseASCII(BYTE b) Line 6129  static void ParseASCII(BYTE b)
6129  // UTF-8で受信データを処理する  // UTF-8で受信データを処理する
6130  // returns TRUE if b is processed  // returns TRUE if b is processed
6131  //  (actually allways returns TRUE)  //  (actually allways returns TRUE)
6132  static BOOL ParseFirstUTF8(BYTE b, int proc_combining)  static BOOL ParseFirstUTF8(BYTE b)
6133  {  {
6134          static BYTE buf[4];          static BYTE buf[4];
6135          static int count = 0;          static int count = 0;
         static int can_combining = 0;  
         static unsigned int first_code;  
         static int first_code_index;  
6136    
6137          unsigned int code;          unsigned int code;
         unsigned short cset;  
6138    
6139          if (ts.FallbackToCP932 && Fallbacked) {          if (ts.FallbackToCP932 && Fallbacked) {
6140                  return ParseFirstJP(b);                  return ParseFirstJP(b);
# Line 6148  static BOOL ParseFirstUTF8(BYTE b, int p Line 6144  static BOOL ParseFirstUTF8(BYTE b, int p
6144                  // 1バイト目および2バイト目がASCIIの場合は、すべてASCII出力とする。                  // 1バイト目および2バイト目がASCIIの場合は、すべてASCII出力とする。
6145                  // 1バイト目がC1制御文字(0x80-0x9f)の場合も同様。                  // 1バイト目がC1制御文字(0x80-0x9f)の場合も同様。
6146                  if (count == 0 || count == 1) {                  if (count == 0 || count == 1) {
                         if (proc_combining == 1 && can_combining == 1) {  
                                 PutU32(first_code);  
                                 can_combining = 0;  
                         }  
   
6147                          if (count == 1) {                          if (count == 1) {
6148                                  ParseASCII(buf[0]);                                  ParseASCII(buf[0]);
6149                          }                          }
# Line 6171  static BOOL ParseFirstUTF8(BYTE b, int p Line 6162  static BOOL ParseFirstUTF8(BYTE b, int p
6162          if ((buf[0] & 0xe0) == 0xc0) {          if ((buf[0] & 0xe0) == 0xc0) {
6163                  if ((buf[1] & 0xc0) == 0x80) {                  if ((buf[1] & 0xc0) == 0x80) {
6164    
                         if (proc_combining == 1 && can_combining == 1) {  
                                 PutU32(first_code);  
                                 can_combining = 0;  
                         }  
   
6165                          code = ((buf[0] & 0x1f) << 6);                          code = ((buf[0] & 0x1f) << 6);
6166                          code |= ((buf[1] & 0x3f));                          code |= ((buf[1] & 0x3f));
6167    
# Line 6206  static BOOL ParseFirstUTF8(BYTE b, int p Line 6192  static BOOL ParseFirstUTF8(BYTE b, int p
6192                  code |= ((buf[1] & 0x3f) << 6);                  code |= ((buf[1] & 0x3f) << 6);
6193                  code |= ((buf[2] & 0x3f));                  code |= ((buf[2] & 0x3f));
6194    
                 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つめの文字が半濁点の1文字目に相当する場合は、再度検索を続ける。(2005.10.15 yutaka)  
                                         first_code_index = UnicodeGetIndexOfCombiningFirstCode(code);  
                                         if (first_code_index != -1) {  
                                                 // 1つめの文字はそのまま出力する  
                                                 PutU32(first_code);  
   
                                                 can_combining = 1;  
                                                 first_code = code;  
                                                 count = 0;  
                                                 return (TRUE);  
                                         }  
   
                                         PutU32(first_code);  
                                         PutU32(code);  
                                         count = 0;  
                                         return (TRUE);  
                                 }  
                         }  
                 }  
   
6195                  PutU32(code);                  PutU32(code);
6196    
6197  skip:  skip:
# Line 6292  static void ParseFirst(BYTE b) Line 6242  static void ParseFirst(BYTE b)
6242  {  {
6243          switch (ts.Language) {          switch (ts.Language) {
6244            case IdUtf8:            case IdUtf8:
6245                  ParseFirstUTF8(b, ts.KanjiCode == IdUTF8m);                    ParseFirstUTF8(b);
6246                  return;                  return;
6247    
6248            case IdJapanese:            case IdJapanese:
6249                  switch (ts.KanjiCode) {                  switch (ts.KanjiCode) {
6250                    case IdUTF8:                    case IdUTF8:
6251                          if (ParseFirstUTF8(b, 0)) {                            if (ParseFirstUTF8(b)) {
6252                                  return;                                  return;
6253                          }                          }
6254                          break;                          break;
6255                    case IdUTF8m:                    case IdUTF8m:
6256                          if (ParseFirstUTF8(b, 1)) {                            if (ParseFirstUTF8(b)) {
6257                                  return;                                  return;
6258                          }                          }
6259                          break;                          break;
# Line 6317  static void ParseFirst(BYTE b) Line 6267  static void ParseFirst(BYTE b)
6267            case IdKorean:            case IdKorean:
6268                  switch (ts.KanjiCode) {                  switch (ts.KanjiCode) {
6269                    case IdUTF8:                    case IdUTF8:
6270                          if (ParseFirstUTF8(b, 0)) {                          if (ParseFirstUTF8(b)) {
6271                                  return;                                  return;
6272                          }                          }
6273                          break;                          break;
6274                    case IdUTF8m:                    case IdUTF8m:
6275                          if (ParseFirstUTF8(b, 1)) {                          if (ParseFirstUTF8(b)) {
6276                                  return;                                  return;
6277                          }                          }
6278                          break;                          break;
# Line 6336  static void ParseFirst(BYTE b) Line 6286  static void ParseFirst(BYTE b)
6286            case IdRussian:            case IdRussian:
6287                  switch (ts.KanjiCode) {                  switch (ts.KanjiCode) {
6288                  case IdUTF8:                  case IdUTF8:
6289                          if (ParseFirstUTF8(b, 0)) {                          if (ParseFirstUTF8(b)) {
6290                                  return;                                  return;
6291                          }                          }
6292                          break;                          break;
# Line 6350  static void ParseFirst(BYTE b) Line 6300  static void ParseFirst(BYTE b)
6300          case IdChinese:          case IdChinese:
6301                  switch (ts.KanjiCode) {                  switch (ts.KanjiCode) {
6302                  case IdUTF8:                  case IdUTF8:
6303                          if (ParseFirstUTF8(b, 0)) {                          if (ParseFirstUTF8(b)) {
6304                                  return;                                  return;
6305                          }                          }
6306                          break;                          break;

Legend:
Removed from v.9499  
changed lines
  Added in v.9525

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26