ctype-ujis.c
上传用户:tsgydb
上传日期:2007-04-14
资源大小:10674k
文件大小:8k
源码类别:

MySQL数据库

开发平台:

Visual C++

  1. /* This file is for Japanese EUC charset, and created by tommy@valley.ne.jp.
  2.  */
  3. /*
  4.  * This comment is parsed by configure to create ctype.c,
  5.  * so don't change it unless you know what you are doing.
  6.  *
  7.  * .configure. mbmaxlen_ujis=3
  8.  */
  9. #include <global.h>
  10. #include "m_string.h"
  11. uchar NEAR ctype_ujis[257] =
  12. {
  13.     0, /* For standard library */
  14.     0040, 0040, 0040, 0040, 0040, 0040, 0040, 0040, /* NUL ^A - ^G */
  15.     0040, 0050, 0050, 0050, 0050, 0050, 0040, 0040, /* ^H - ^O */
  16.     0040, 0040, 0040, 0040, 0040, 0040, 0040, 0040, /* ^P - ^W */
  17.     0040, 0040, 0040, 0040, 0040, 0040, 0040, 0040, /* ^X - ^Z ^[ ^ ^] ^^ ^_ */
  18.     0110, 0020, 0020, 0020, 0020, 0020, 0020, 0020, /* SPC ! " # $ % ^ ' */
  19.     0020, 0020, 0020, 0020, 0020, 0020, 0020, 0020, /* ( ) * + , - . / */
  20.     0204, 0204, 0204, 0204, 0204, 0204, 0204, 0204, /* 0 1 2 3 4 5 6 7 */
  21.     0204, 0204, 0020, 0020, 0020, 0020, 0020, 0020, /* 8 9 : ; < = > ? */
  22.     0020, 0201, 0201, 0201, 0201, 0201, 0201, 0001, /* @ A B C D E F G */
  23.     0001, 0001, 0001, 0001, 0001, 0001, 0001, 0001, /* H I J K L M N O */
  24.     0001, 0001, 0001, 0001, 0001, 0001, 0001, 0001, /* P Q R S T U V W */
  25.     0001, 0001, 0001, 0020, 0020, 0020, 0020, 0020, /* X Y Z [  ] ^ _ */
  26.     0020, 0202, 0202, 0202, 0202, 0202, 0202, 0002, /* ` a b c d e f g */
  27.     0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002, /* h i j k l m n o */
  28.     0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002, /* p q r s t u v w */
  29.     0002, 0002, 0002, 0020, 0020, 0020, 0020, 0040, /* x y z { | } + DEL */
  30.     0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000,
  31.     0000, 0000, 0000, 0000, 0000, 0000, 0020, 0020,
  32.     0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000,
  33.     0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000,
  34.     0000, 0020, 0020, 0020, 0020, 0020, 0020, 0020,
  35.     0020, 0020, 0020, 0020, 0020, 0020, 0020, 0020,
  36.     0020, 0020, 0020, 0020, 0020, 0020, 0020, 0020,
  37.     0020, 0020, 0020, 0020, 0020, 0020, 0020, 0020,
  38.     0020, 0020, 0020, 0020, 0020, 0020, 0020, 0020,
  39.     0020, 0020, 0020, 0020, 0020, 0020, 0020, 0020,
  40.     0020, 0020, 0020, 0020, 0020, 0020, 0020, 0020,
  41.     0020, 0020, 0020, 0020, 0020, 0020, 0020, 0020,
  42.     0020, 0020, 0020, 0020, 0020, 0020, 0020, 0020,
  43.     0020, 0020, 0020, 0020, 0020, 0020, 0020, 0020,
  44.     0020, 0020, 0020, 0020, 0020, 0020, 0020, 0020,
  45.     0020, 0020, 0020, 0020, 0020, 0020, 0020, 0000,
  46. };
  47. uchar NEAR to_lower_ujis[]=
  48. {
  49.   '00','01','02','03','04','05','06','07',
  50.   '10','11','12','13','14','15','16','17',
  51.   '20','21','22','23','24','25','26','27',
  52.   '30','31','32','33','34','35','36','37',
  53.   ' ',  '!', '"',   '#',   '$',   '%',   '&',   ''',
  54.   '(',  ')', '*',   '+',   ',',   '-',   '.',   '/',
  55.   '0',  '1', '2',   '3',   '4',   '5',   '6',   '7',
  56.   '8',  '9', ':',   ';',   '<',   '=',   '>',   '?',
  57.   '@',  'a', 'b',   'c',   'd',   'e',   'f',   'g',
  58.   'h',  'i', 'j',   'k',   'l',   'm',   'n',   'o',
  59.   'p',  'q', 'r',   's',   't',   'u',   'v',   'w',
  60.   'x',  'y', 'z',   '[',   '\',  ']',   '^',   '_',
  61.   '`',  'a', 'b',   'c',   'd',   'e',   'f',   'g',
  62.   'h',  'i', 'j',   'k',   'l',   'm',   'n',   'o',
  63.   'p',  'q', 'r',   's',   't',   'u',   'v',   'w',
  64.   'x',  'y', 'z',   '{',   '|',   '}',   '~',   '177',
  65.   '200','201','202','203','204','205','206','207',
  66.   '210','211','212','213','214','215','216','217',
  67.   '220','221','222','223','224','225','226','227',
  68.   '230','231','232','233','234','235','236','237',
  69.   '240','241','242','243','244','245','246','247',
  70.   '250','251','252','253','254','255','256','257',
  71.   '260','261','262','263','264','265','266','267',
  72.   '270','271','272','273','274','275','276','277',
  73.   '300','301','302','303','304','305','306','307',
  74.   '310','311','312','313','314','315','316','317',
  75.   '320','321','322','323','324','325','326','327',
  76.   '330','331','332','333','334','335','336','337',
  77.   '340','341','342','343','344','345','346','347',
  78.   '350','351','352','353','354','355','356','357',
  79.   '360','361','362','363','364','365','366','367',
  80.   '370','371','372','373','374','375','376','377',
  81. };
  82. uchar NEAR to_upper_ujis[]=
  83. {
  84.   '00','01','02','03','04','05','06','07',
  85.   '10','11','12','13','14','15','16','17',
  86.   '20','21','22','23','24','25','26','27',
  87.   '30','31','32','33','34','35','36','37',
  88.   ' ',  '!', '"',   '#',   '$',   '%',   '&',   ''',
  89.   '(',  ')', '*',   '+',   ',',   '-',   '.',   '/',
  90.   '0',  '1', '2',   '3',   '4',   '5',   '6',   '7',
  91.   '8',  '9', ':',   ';',   '<',   '=',   '>',   '?',
  92.   '@',  'A', 'B',   'C',   'D',   'E',   'F',   'G',
  93.   'H',  'I', 'J',   'K',   'L',   'M',   'N',   'O',
  94.   'P',  'Q', 'R',   'S',   'T',   'U',   'V',   'W',
  95.   'X',  'Y', 'Z',   '[',   '\',  ']',   '^',   '_',
  96.   '`',  'A', 'B',   'C',   'D',   'E',   'F',   'G',
  97.   'H',  'I', 'J',   'K',   'L',   'M',   'N',   'O',
  98.   'P',  'Q', 'R',   'S',   'T',   'U',   'V',   'W',
  99.   'X',  'Y', 'Z',   '{',   '|',   '}',   '~',   '177',
  100.   '200','201','202','203','204','205','206','207',
  101.   '210','211','212','213','214','215','216','217',
  102.   '220','221','222','223','224','225','226','227',
  103.   '230','231','232','233','234','235','236','237',
  104.   '240','241','242','243','244','245','246','247',
  105.   '250','251','252','253','254','255','256','257',
  106.   '260','261','262','263','264','265','266','267',
  107.   '270','271','272','273','274','275','276','277',
  108.   '300','301','302','303','304','305','306','307',
  109.   '310','311','312','313','314','315','316','317',
  110.   '320','321','322','323','324','325','326','327',
  111.   '330','331','332','333','334','335','336','337',
  112.   '340','341','342','343','344','345','346','347',
  113.   '350','351','352','353','354','355','356','357',
  114.   '360','361','362','363','364','365','366','367',
  115.   '370','371','372','373','374','375','376','377',
  116. };
  117. uchar NEAR sort_order_ujis[]=
  118. {
  119.   '00','01','02','03','04','05','06','07',
  120.   '10','11','12','13','14','15','16','17',
  121.   '20','21','22','23','24','25','26','27',
  122.   '30','31','32','33','34','35','36','37',
  123.   ' ',  '!', '"',   '#',   '$',   '%',   '&',   ''',
  124.   '(',  ')', '*',   '+',   ',',   '-',   '.',   '/',
  125.   '0',  '1', '2',   '3',   '4',   '5',   '6',   '7',
  126.   '8',  '9', ':',   ';',   '<',   '=',   '>',   '?',
  127.   '@',  'A', 'B',   'C',   'D',   'E',   'F',   'G',
  128.   'H',  'I', 'J',   'K',   'L',   'M',   'N',   'O',
  129.   'P',  'Q', 'R',   'S',   'T',   'U',   'V',   'W',
  130.   'X',  'Y', 'Z',   '[',   '\',  ']',   '^',   '_',
  131.   '`',  'A', 'B',   'C',   'D',   'E',   'F',   'G',
  132.   'H',  'I', 'J',   'K',   'L',   'M',   'N',   'O',
  133.   'P',  'Q', 'R',   'S',   'T',   'U',   'V',   'W',
  134.   'X',  'Y', 'Z',   '{',   '|',   '}',   '~',   '177',
  135.   '200','201','202','203','204','205','206','207',
  136.   '210','211','212','213','214','215','216','217',
  137.   '220','221','222','223','224','225','226','227',
  138.   '230','231','232','233','234','235','236','237',
  139.   '240','241','242','243','244','245','246','247',
  140.   '250','251','252','253','254','255','256','257',
  141.   '260','261','262','263','264','265','266','267',
  142.   '270','271','272','273','274','275','276','277',
  143.   '300','301','302','303','304','305','306','307',
  144.   '310','311','312','313','314','315','316','317',
  145.   '320','321','322','323','324','325','326','327',
  146.   '330','331','332','333','334','335','336','337',
  147.   '340','341','342','343','344','345','346','347',
  148.   '350','351','352','353','354','355','356','357',
  149.   '360','361','362','363','364','365','366','367',
  150.   '370','371','372','373','374','375','376','377',
  151. };
  152. #define isujis(c)     ((0xa1<=((c)&0xff) && ((c)&0xff)<=0xfe))
  153. #define iskata(c)     ((0xa1<=((c)&0xff) && ((c)&0xff)<=0xdf))
  154. #define isujis_ss2(c) (((c)&0xff) == 0x8e)
  155. #define isujis_ss3(c) (((c)&0xff) == 0x8f)
  156. int ismbchar_ujis(const char* p, const char *e)
  157. {
  158.   return ((*(uchar*)(p)<0x80)? 0:
  159.     isujis(*(p)) && (e)-(p)>1 && isujis(*((p)+1))? 2:
  160.     isujis_ss2(*(p)) && (e)-(p)>1 && iskata(*((p)+1))? 2:
  161.     isujis_ss3(*(p)) && (e)-(p)>2 && isujis(*((p)+1)) && isujis(*((p)+2))? 3:
  162.     0);
  163. }
  164. my_bool ismbhead_ujis(uint c)
  165. {
  166.   return (isujis(c) || isujis_ss2(c) || isujis_ss3(c));
  167. }
  168. int mbcharlen_ujis(uint c)
  169. {
  170.   return (isujis(c)? 2: isujis_ss2(c)? 2: isujis_ss3(c)? 3: 0);
  171. }