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 7461 by zmatsuo, Tue Mar 5 16:22:05 2019 UTC revision 7462 by zmatsuo, Sat Mar 9 17:32:42 2019 UTC
# Line 52  Line 52 
52  #include "telnet.h"  #include "telnet.h"
53  #include "ttime.h"  #include "ttime.h"
54  #include "clipboar.h"  #include "clipboar.h"
55  #include "../ttpcmn/language.h"  #include "codeconv.h"
56    #include "codeconv.h"
57    
58  #include "vtterm.h"  #include "vtterm.h"
59    
# Line 5408  static void ParseASCII(BYTE b) Line 5409  static void ParseASCII(BYTE b)
5409  }  }
5410    
5411  //  //
 // UTF-8  
 //  
 #include "uni2sjis.map"  
 #include "unisym2decsp.map"  
   
   
 //  
5412  // Unicode Combining Character Support  // Unicode Combining Character Support
5413  //  //
5414  #include "uni_combining.map"  #include "uni_combining.map"
# Line 5467  static int GetIndexOfCombiningFirstCode( Line 5461  static int GetIndexOfCombiningFirstCode(
5461          return (index);          return (index);
5462  }  }
5463    
5464  // unicode(UTF-16,wchar_t)をバッファへ書き込む  // unicode(UTF-32,wchar_t)をバッファへ書き込む
5465  static void UnicodeToCP932(unsigned int code)  static void UnicodeToCP932(unsigned int code)
5466  {  {
5467          wchar_t wchar = (wchar_t)code;          wchar_t wchar;
5468          int ret;          int ret;
5469          char mbchar[2];          char mbchar[2];
5470          unsigned short cset;          unsigned short cset;
5471    
5472            if (code >= 0x10000) {
5473                    goto unknown;
5474            }
5475            wchar = (wchar_t)code;
5476    
5477          // UnicodeからDEC特殊文字へのマッピング          // UnicodeからDEC特殊文字へのマッピング
5478          if (ts.UnicodeDecSpMapping) {          if (ts.UnicodeDecSpMapping) {
5479                  cset = ConvertUnicode(wchar, mapUnicodeSymbolToDecSp, MAPSIZE(mapUnicodeSymbolToDecSp));                  cset = UTF32ToDecSp(wchar);
5480                  if (((cset >> 8) & ts.UnicodeDecSpMapping) != 0) {                  if (((cset >> 8) & ts.UnicodeDecSpMapping) != 0) {
5481                          PutDecSp(cset & 0xff);                          PutDecSp(cset & 0xff);
5482                          return;                          return;
# Line 5485  static void UnicodeToCP932(unsigned int Line 5484  static void UnicodeToCP932(unsigned int
5484          }          }
5485    
5486          // Unicode -> 内部コード(ts.CodePage)へ変換して出力          // Unicode -> 内部コード(ts.CodePage)へ変換して出力
5487          ret = WideCharToMultiByte(ts.CodePage, 0, &wchar, 1, mbchar, 2, NULL, NULL);          if (ts.CodePage == 932) {
5488                    ret = (int)UTF16ToCP932(&wchar, 1, &cset);
5489                    if (ret == 0) {
5490                            // 変換できなかった
5491                            ;
5492                    } else if (cset < 0x100) {
5493                            // 1byte文字
5494                            mbchar[0] = (char)cset;
5495                            ret = 1;
5496                    } else {
5497                            // 2byte文字
5498                            mbchar[0] = (char)(cset >> 8);
5499                            mbchar[1] = (char)(cset & 0xff);
5500                            ret = 2;
5501                    }
5502            } else {
5503                    ret = WideCharToMultiByte(ts.CodePage, 0, &wchar, 1, mbchar, 2, NULL, NULL);
5504            }
5505          if (ret == 1 && mbchar[0] == '?' && code != '?') {          if (ret == 1 && mbchar[0] == '?' && code != '?') {
5506                  // 変換できなかったとき、ret=1, '?' を返してくる                  // 変換できなかったとき、ret=1, '?' を返してくる
5507                  ret = 0;                  ret = 0;
5508          }          }
5509          switch (ret) {          switch (ret) {
5510          case 0:          case 0:
5511                  if (ts.CodePage == 932) {          unknown:
                         // CP932  
                         // U+301Cなどは変換できない。Unicode -> Shift_JISへ変換してみる。  
                         cset = ConvertUnicode(code, mapUnicodeToSJIS, MAPSIZE(mapUnicodeToSJIS));  
                         if (cset != 0) {  
                                 Kanji = cset & 0xff00;  
                                 PutKanji(cset & 0x00ff);  
                                 return;  
                         }  
                 }  
   
5512                  PutChar('?');                  PutChar('?');
5513                  if (ts.UnknownUnicodeCharaAsWide) {                  if (ts.UnknownUnicodeCharaAsWide) {
5514                          PutChar('?');                          PutChar('?');

Legend:
Removed from v.7461  
changed lines
  Added in v.7462

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