1 /* 2 * $Id: cplib.h,v 1.4 2001/06/18 09:09:32 ura Exp $ 3 */ 4 5 /* 6 * FreeWnn is a network-extensible Kana-to-Kanji conversion system. 7 * This file is part of FreeWnn. 8 * 9 * Copyright Kyoto University Research Institute for Mathematical Sciences 10 * 1987, 1988, 1989, 1990, 1991, 1992 11 * Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991, 1992, 1999 12 * Copyright ASTEC, Inc. 1987, 1988, 1989, 1990, 1991, 1992 13 * Copyright FreeWnn Project 1999, 2000 14 * 15 * Maintainer: FreeWnn Project <freewnn@tomo.gr.jp> 16 * 17 * This program is free software; you can redistribute it and/or modify 18 * it under the terms of the GNU General Public License as published by 19 * the Free Software Foundation; either version 2 of the License, or 20 * (at your option) any later version. 21 * 22 * This program is distributed in the hope that it will be useful, 23 * but WITHOUT ANY WARRANTY; without even the implied warranty of 24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 25 * GNU General Public License for more details. 26 * 27 * You should have received a copy of the GNU General Public License 28 * along with this program; if not, write to the Free Software 29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 30 */ 31 32 #ifndef WNN_CPLIB_H 33 #define WNN_CPLIB_H 34 35 /** cWnn Version 1.1 **/ 36 37 #ifndef min 38 #define min(a,b) ((int)(a) > (int)(b)? (b):(a)) 39 #endif 40 41 #define YIN_LEN 10 42 #define PY_LEN 10 /* 'Chuang��', 'Zhuang��' */ 43 #define PY_LEN_W 7 /* for w_char */ 44 45 #define PY_MARK 'P' /* for PinYincode: to know if need to change to */ 46 #define ZY_MARK 'Z' /* for PinYincode: to know if need to change to */ 47 #define CWNN_PINYIN 0 /* For Pinyin */ 48 #define CWNN_ZHUYIN 1 /* For Zhuyin */ 49 50 51 #define PY_EOF 0x8ec0 /* PY_EOF is end charactor of one PinYin 52 must be a 2 bytes code. HUANG */ 53 #define ZY_EOF_0 0x8ec0 /* ZhuYin end character(no sisheng): '��' */ 54 #define ZY_EOF_1 0x8ec1 /* ZhuYin end character(sisheng 1 ): '��' */ 55 #define ZY_EOF_2 0x8ec2 /* ZhuYin end character(sisheng 2 ): '��' */ 56 #define ZY_EOF_3 0x8ec3 /* ZhuYin end character(sisheng 3 ): '��' */ 57 #define ZY_EOF_4 0x8ec4 /* ZhuYin end character(sisheng 4 ): '��' */ 58 59 #define isZY_EOF(X) ( ((int)(X) >= ZY_EOF_0 && (int)(X) <= ZY_EOF_4 )? 1 : 0 ) 60 61 #define PY_NUM_SHENGMU 24 /* ShengMu table size of PinYin */ 62 #define PY_NUM_YUNMU 39 /* YunMu table size of PinYin */ 63 #define ZY_NUM_SHENGMU 24 /* ShengMu table size of ZhuYin */ 64 #define ZY_NUM_YUNMU 41 /* YunMu table size of ZhuYin */ 65 66 #define EMPTY_SHENG_RAW 0 /* position of ShengMu EMPTY in ShengMu 67 table */ 68 #define EMPTY_YUN_RAW 0 /* position of YunMu EMPTY in YunMu 69 table */ 70 #define X_SHENG_RAW 20 /* position of ShengMu X in ShengMu 71 table */ 72 73 /* YINcode creating is based on PinYin */ 74 /* isyincod_d(): Check it is in the domain of Pinyin. To check if it is a 75 Pinyin, you need to use cp_isyincod() wihich checks the PinYin table */ 76 #define _cwnn_isyincod_d(c) ( ((c & 0x80) && \ 77 (!(c & 0x8000)) && \ 78 (c & 0x7f) >= 0x20 && \ 79 (((int)c >> (int)8) & 0x7f) >= 0x20 ) \ 80 ?1:0 ) /* if is in YINcode's limite */ 81 82 #define _cwnn_sisheng(YINcod) ( ((YINcod & 0x100) == 0x100)? \ 83 ((YINcod & 0x03 ) + 1): 0 ) 84 85 #define _cwnn_yincod_0(YINcod) ((YINcod) & 0xfefc) 86 87 /* Shengraw based on PinYin table */ 88 #define Shengraw(YINcod) (((int)((YINcod - 0x20a0) & 0x7c)>>(int)2) + 0x01) 89 90 /* Yunraw based on PinYin table */ 91 #define Yunraw(YINcod) ((int)(((YINcod) - 0x20a0) & 0x7e00) >> (int)9) 92 93 94 /* to see if the char is a start char of a pinyin without sisheng */ 95 #define py0_first_ch(X) (((int)(X)>'A' && (int)(X)<='Z' && \ 96 (X)!='E' && (X)!='O'&& \ 97 (X)!='I' && (X)!='U' && (X)!='V') || \ 98 (X)=='a'||(X)=='e'||(X)=='o' || (X)=='n'? 1: 0) 99 100 /* to see if the char is a start char of a zhuyin */ 101 102 /* for sisheng */ 103 #define S_S_YOMI(X) ( ((int)(X&0xff)>=0xa1)&&((int)(X&0xff)<=0xbf))||((int)(X>>8)==0x8e) 104 #define py_first_ch(X) ( py0_first_ch(X) || S_S_YOMI(X) ) 105 #define zy_first_ch(X) ( ((int)(X&0xff) >= 0xc0 && (int)(X&0xff) <= 0xe9 && \ 106 ((int)(X>>(int)8)) == 0x8e) ) 107 108 #define _cwnn_has_sisheng(YINcod) ( (( (YINcod)& 0x0100) != 0 ) ?1:0) 109 110 extern unsigned char last_mark; 111 112 extern char *py_shengmu_tbl[]; /* PinYin ShengMu table */ 113 extern char *py_yunmu_tbl[]; /* PinYin YunMu table */ 114 extern char *zy_shengmu_tbl[]; /* ZhuYin ShengMu table */ 115 extern char *zy_yunmu_tbl[]; /* ZhuYin YunMu table */ 116 117 extern int pinyin_tbl[]; /* PinYin table */ 118 extern int zhuyin_tbl[]; /* ZhuYin table */ 119 120 #endif /* WNN_CPLIB_H */ 121