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 6512 by doda, Thu Oct 27 03:06:36 2016 UTC revision 6514 by doda, Thu Oct 27 03:06:43 2016 UTC
# Line 5187  extern unsigned short ConvertUnicode(uns Line 5187  extern unsigned short ConvertUnicode(uns
5187    
5188    
5189  //  //
5190  // UTF-8 for Mac OS X(HFS plus)  // Unicode Combining Character Support
5191  //  //
5192  #include "hfs_plus.map"  #include "uni_combining.map"
5193    
5194  unsigned short GetIllegalUnicode(int start_index, unsigned short first_code, unsigned short code,  unsigned short GetPrecomposedChar(int start_index, unsigned short first_code, unsigned short code,
5195                                                                   hfsplus_codemap_t *table, int tmax)                                                                   combining_map_t *table, int tmax)
5196  {  {
5197          unsigned short result = 0;          unsigned short result = 0;
5198          int i;          int i;
# Line 5203  unsigned short GetIllegalUnicode(int sta Line 5203  unsigned short GetIllegalUnicode(int sta
5203                  }                  }
5204    
5205                  if (table[i].second_code == code) {                  if (table[i].second_code == code) {
5206                          result = table[i].illegal_code;                          result = table[i].precomposed;
5207                          break;                          break;
5208                  }                  }
5209          }          }
# Line 5211  unsigned short GetIllegalUnicode(int sta Line 5211  unsigned short GetIllegalUnicode(int sta
5211          return (result);          return (result);
5212  }  }
5213    
5214  int GetIndexOfHFSPlusFirstCode(unsigned short code, hfsplus_codemap_t *table, int tmax)  int GetIndexOfCombiningFirstCode(unsigned short code, combining_map_t *table, int tmax)
5215  {  {
5216          int low, mid, high;          int low, mid, high;
5217          int index = -1;          int index = -1;
# Line 5296  static void UnicodeToCP932(unsigned int Line 5296  static void UnicodeToCP932(unsigned int
5296  }  }
5297    
5298  // UTF-8で受信データを処理する  // UTF-8で受信データを処理する
5299  BOOL ParseFirstUTF8(BYTE b, int hfsplus_mode)  BOOL ParseFirstUTF8(BYTE b, int proc_combining)
5300  // returns TRUE if b is processed  // returns TRUE if b is processed
5301  //  (actually allways returns TRUE)  //  (actually allways returns TRUE)
5302  {  {
5303          static BYTE buf[3];          static BYTE buf[3];
5304          static int count = 0;          static int count = 0;
5305          static int maybe_hfsplus = 0;          static int can_combining = 0;
5306          static unsigned int first_code;          static unsigned int first_code;
5307          static int first_code_index;          static int first_code_index;
5308    
# Line 5317  BOOL ParseFirstUTF8(BYTE b, int hfsplus_ Line 5317  BOOL ParseFirstUTF8(BYTE b, int hfsplus_
5317                  // 1バイト目および2バイト目がASCIIの場合は、すべてASCII出力とする。                  // 1バイト目および2バイト目がASCIIの場合は、すべてASCII出力とする。
5318                  // 1バイト目がC1制御文字(0x80-0x9f)の場合も同様。                  // 1バイト目がC1制御文字(0x80-0x9f)の場合も同様。
5319                  if (count == 0 || count == 1) {                  if (count == 0 || count == 1) {
5320                          if (hfsplus_mode == 1 && maybe_hfsplus == 1) {                          if (proc_combining == 1 && can_combining == 1) {
5321                                  UnicodeToCP932(first_code);                                  UnicodeToCP932(first_code);
5322                                  maybe_hfsplus = 0;                                  can_combining = 0;
5323                          }                          }
5324    
5325                          if (count == 1) {                          if (count == 1) {
# Line 5343  BOOL ParseFirstUTF8(BYTE b, int hfsplus_ Line 5343  BOOL ParseFirstUTF8(BYTE b, int hfsplus_
5343          if ((buf[0] & 0xe0) == 0xc0) {          if ((buf[0] & 0xe0) == 0xc0) {
5344                  if ((buf[1] & 0xc0) == 0x80) {                  if ((buf[1] & 0xc0) == 0x80) {
5345    
5346                          if (hfsplus_mode == 1 && maybe_hfsplus == 1) {                          if (proc_combining == 1 && can_combining == 1) {
5347                                  UnicodeToCP932(first_code);                                  UnicodeToCP932(first_code);
5348                                  maybe_hfsplus = 0;                                  can_combining = 0;
5349                          }                          }
5350    
5351                          code = ((buf[0] & 0x1f) << 6);                          code = ((buf[0] & 0x1f) << 6);
# Line 5378  BOOL ParseFirstUTF8(BYTE b, int hfsplus_ Line 5378  BOOL ParseFirstUTF8(BYTE b, int hfsplus_
5378                  code |= ((buf[1] & 0x3f) << 6);                  code |= ((buf[1] & 0x3f) << 6);
5379                  code |= ((buf[2] & 0x3f));                  code |= ((buf[2] & 0x3f));
5380    
5381                  if (hfsplus_mode == 1) {                  if (proc_combining == 1) {
5382                          if (maybe_hfsplus == 0) {                          if (can_combining == 0) {
5383                                  if ((first_code_index = GetIndexOfHFSPlusFirstCode(                                  if ((first_code_index = GetIndexOfCombiningFirstCode(
5384                                                  code, mapHFSPlusUnicode, MAPSIZE(mapHFSPlusUnicode)                                                  code, mapCombiningToPrecomposed, MAPSIZE(mapCombiningToPrecomposed)
5385                                                  )) != -1) {                                                  )) != -1) {
5386                                          maybe_hfsplus = 1;                                          can_combining = 1;
5387                                          first_code = code;                                          first_code = code;
5388                                          count = 0;                                          count = 0;
5389                                          return (TRUE);                                          return (TRUE);
5390                                  }                                  }
5391                          } else {                          } else {
5392                                  maybe_hfsplus = 0;                                  can_combining = 0;
5393                                  cset = GetIllegalUnicode(first_code_index, first_code, code, mapHFSPlusUnicode, MAPSIZE(mapHFSPlusUnicode));                                  cset = GetPrecomposedChar(first_code_index, first_code, code, mapCombiningToPrecomposed, MAPSIZE(mapCombiningToPrecomposed));
5394                                  if (cset != 0) { // success                                  if (cset != 0) { // success
5395                                          code = cset;                                          code = cset;
5396    
5397                                  } else { // error                                  } else { // error
5398                                          // 2つめの文字が半濁点の1文字目に相当する場合は、再度検索を続ける。(2005.10.15 yutaka)                                          // 2つめの文字が半濁点の1文字目に相当する場合は、再度検索を続ける。(2005.10.15 yutaka)
5399                                          if ((first_code_index = GetIndexOfHFSPlusFirstCode(                                          if ((first_code_index = GetIndexOfCombiningFirstCode(
5400                                                          code, mapHFSPlusUnicode, MAPSIZE(mapHFSPlusUnicode)                                                          code, mapCombiningToPrecomposed, MAPSIZE(mapCombiningToPrecomposed)
5401                                                          )) != -1) {                                                          )) != -1) {
5402    
5403                                                  // 1つめの文字はそのまま出力する                                                  // 1つめの文字はそのまま出力する
5404                                                  UnicodeToCP932(first_code);                                                  UnicodeToCP932(first_code);
5405    
5406                                                  maybe_hfsplus = 1;                                                  can_combining = 1;
5407                                                  first_code = code;                                                  first_code = code;
5408                                                  count = 0;                                                  count = 0;
5409                                                  return (TRUE);                                                  return (TRUE);

Legend:
Removed from v.6512  
changed lines
  Added in v.6514

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