1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/intl/unicharutil/src/ucdata.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,306 @@ 1.4 +/* 1.5 + * Copyright 1996, 1997, 1998 Computing Research Labs, 1.6 + * New Mexico State University 1.7 + * 1.8 + * Permission is hereby granted, free of charge, to any person obtaining a 1.9 + * copy of this software and associated documentation files (the "Software"), 1.10 + * to deal in the Software without restriction, including without limitation 1.11 + * the rights to use, copy, modify, merge, publish, distribute, sublicense, 1.12 + * and/or sell copies of the Software, and to permit persons to whom the 1.13 + * Software is furnished to do so, subject to the following conditions: 1.14 + * 1.15 + * The above copyright notice and this permission notice shall be included in 1.16 + * all copies or substantial portions of the Software. 1.17 + * 1.18 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1.19 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1.20 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 1.21 + * THE COMPUTING RESEARCH LAB OR NEW MEXICO STATE UNIVERSITY BE LIABLE FOR ANY 1.22 + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT 1.23 + * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR 1.24 + * THE USE OR OTHER DEALINGS IN THE SOFTWARE. 1.25 + */ 1.26 +#ifndef _h_ucdata 1.27 +#define _h_ucdata 1.28 + 1.29 +/* 1.30 + * $Id: ucdata.h,v 1.1 1999/01/08 00:19:12 ftang%netscape.com Exp $ 1.31 + */ 1.32 + 1.33 +#ifdef __cplusplus 1.34 +extern "C" { 1.35 +#endif 1.36 + 1.37 +#undef __ 1.38 +#ifdef __STDC__ 1.39 +#define __(x) x 1.40 +#else 1.41 +#define __(x) () 1.42 +#endif 1.43 + 1.44 +#define UCDATA_VERSION "1.9" 1.45 + 1.46 +/************************************************************************** 1.47 + * 1.48 + * Masks and macros for character properties. 1.49 + * 1.50 + **************************************************************************/ 1.51 + 1.52 +/* 1.53 + * Values that can appear in the `mask1' parameter of the ucisprop() 1.54 + * function. 1.55 + */ 1.56 +#define UC_MN 0x00000001 /* Mark, Non-Spacing */ 1.57 +#define UC_MC 0x00000002 /* Mark, Spacing Combining */ 1.58 +#define UC_ME 0x00000004 /* Mark, Enclosing */ 1.59 +#define UC_ND 0x00000008 /* Number, Decimal Digit */ 1.60 +#define UC_NL 0x00000010 /* Number, Letter */ 1.61 +#define UC_NO 0x00000020 /* Number, Other */ 1.62 +#define UC_ZS 0x00000040 /* Separator, Space */ 1.63 +#define UC_ZL 0x00000080 /* Separator, Line */ 1.64 +#define UC_ZP 0x00000100 /* Separator, Paragraph */ 1.65 +#define UC_CC 0x00000200 /* Other, Control */ 1.66 +#define UC_CF 0x00000400 /* Other, Format */ 1.67 +#define UC_OS 0x00000800 /* Other, Surrogate */ 1.68 +#define UC_CO 0x00001000 /* Other, Private Use */ 1.69 +#define UC_CN 0x00002000 /* Other, Not Assigned */ 1.70 +#define UC_LU 0x00004000 /* Letter, Uppercase */ 1.71 +#define UC_LL 0x00008000 /* Letter, Lowercase */ 1.72 +#define UC_LT 0x00010000 /* Letter, Titlecase */ 1.73 +#define UC_LM 0x00020000 /* Letter, Modifier */ 1.74 +#define UC_LO 0x00040000 /* Letter, Other */ 1.75 +#define UC_PC 0x00080000 /* Punctuation, Connector */ 1.76 +#define UC_PD 0x00100000 /* Punctuation, Dash */ 1.77 +#define UC_PS 0x00200000 /* Punctuation, Open */ 1.78 +#define UC_PE 0x00400000 /* Punctuation, Close */ 1.79 +#define UC_PO 0x00800000 /* Punctuation, Other */ 1.80 +#define UC_SM 0x01000000 /* Symbol, Math */ 1.81 +#define UC_SC 0x02000000 /* Symbol, Currency */ 1.82 +#define UC_SK 0x04000000 /* Symbol, Modifier */ 1.83 +#define UC_SO 0x08000000 /* Symbol, Other */ 1.84 +#define UC_L 0x10000000 /* Left-To-Right */ 1.85 +#define UC_R 0x20000000 /* Right-To-Left */ 1.86 +#define UC_EN 0x40000000 /* European Number */ 1.87 +#define UC_ES 0x80000000 /* European Number Separator */ 1.88 + 1.89 +/* 1.90 + * Values that can appear in the `mask2' parameter of the ucisprop() 1.91 + * function. 1.92 + */ 1.93 +#define UC_ET 0x00000001 /* European Number Terminator */ 1.94 +#define UC_AN 0x00000002 /* Arabic Number */ 1.95 +#define UC_CS 0x00000004 /* Common Number Separator */ 1.96 +#define UC_B 0x00000008 /* Block Separator */ 1.97 +#define UC_S 0x00000010 /* Segment Separator */ 1.98 +#define UC_WS 0x00000020 /* Whitespace */ 1.99 +#define UC_ON 0x00000040 /* Other Neutrals */ 1.100 +/* 1.101 + * Implementation specific character properties. 1.102 + */ 1.103 +#define UC_CM 0x00000080 /* Composite */ 1.104 +#define UC_NB 0x00000100 /* Non-Breaking */ 1.105 +#define UC_SY 0x00000200 /* Symmetric */ 1.106 +#define UC_HD 0x00000400 /* Hex Digit */ 1.107 +#define UC_QM 0x00000800 /* Quote Mark */ 1.108 +#define UC_MR 0x00001000 /* Mirroring */ 1.109 +#define UC_SS 0x00002000 /* Space, other */ 1.110 + 1.111 +#define UC_CP 0x00004000 /* Defined */ 1.112 + 1.113 +/* 1.114 + * Added for UnicodeData-2.1.3. 1.115 + */ 1.116 +#define UC_PI 0x00008000 /* Punctuation, Initial */ 1.117 +#define UC_PF 0x00010000 /* Punctuation, Final */ 1.118 + 1.119 +/* 1.120 + * This is the primary function for testing to see if a character has some set 1.121 + * of properties. The macros that test for various character properties all 1.122 + * call this function with some set of masks. 1.123 + */ 1.124 +extern int ucisprop __((unsigned long code, unsigned long mask1, 1.125 + unsigned long mask2)); 1.126 + 1.127 +#define ucisalpha(cc) ucisprop(cc, UC_LU|UC_LL|UC_LM|UC_LO|UC_LT, 0) 1.128 +#define ucisdigit(cc) ucisprop(cc, UC_ND, 0) 1.129 +#define ucisalnum(cc) ucisprop(cc, UC_LU|UC_LL|UC_LM|UC_LO|UC_LT|UC_ND, 0) 1.130 +#define uciscntrl(cc) ucisprop(cc, UC_CC|UC_CF, 0) 1.131 +#define ucisspace(cc) ucisprop(cc, UC_ZS|UC_SS, 0) 1.132 +#define ucisblank(cc) ucisprop(cc, UC_ZS, 0) 1.133 +#define ucispunct(cc) ucisprop(cc, UC_PD|UC_PS|UC_PE|UC_PO, UC_PI|UC_PF) 1.134 +#define ucisgraph(cc) ucisprop(cc, UC_MN|UC_MC|UC_ME|UC_ND|UC_NL|UC_NO|\ 1.135 + UC_LU|UC_LL|UC_LT|UC_LM|UC_LO|UC_PC|UC_PD|\ 1.136 + UC_PS|UC_PE|UC_PO|UC_SM|UC_SM|UC_SC|UC_SK|\ 1.137 + UC_SO, UC_PI|UC_PF) 1.138 +#define ucisprint(cc) ucisprop(cc, UC_MN|UC_MC|UC_ME|UC_ND|UC_NL|UC_NO|\ 1.139 + UC_LU|UC_LL|UC_LT|UC_LM|UC_LO|UC_PC|UC_PD|\ 1.140 + UC_PS|UC_PE|UC_PO|UC_SM|UC_SM|UC_SC|UC_SK|\ 1.141 + UC_SO|UC_ZS, UC_PI|UC_PF) 1.142 +#define ucisupper(cc) ucisprop(cc, UC_LU, 0) 1.143 +#define ucislower(cc) ucisprop(cc, UC_LL, 0) 1.144 +#define ucistitle(cc) ucisprop(cc, UC_LT, 0) 1.145 +#define ucisxdigit(cc) ucisprop(cc, 0, UC_HD) 1.146 + 1.147 +#define ucisisocntrl(cc) ucisprop(cc, UC_CC, 0) 1.148 +#define ucisfmtcntrl(cc) ucisprop(cc, UC_CF, 0) 1.149 + 1.150 +#define ucissymbol(cc) ucisprop(cc, UC_SM|UC_SC|UC_SO|UC_SK, 0) 1.151 +#define ucisnumber(cc) ucisprop(cc, UC_ND|UC_NO|UC_NL, 0) 1.152 +#define ucisnonspacing(cc) ucisprop(cc, UC_MN, 0) 1.153 +#define ucisopenpunct(cc) ucisprop(cc, UC_PS, 0) 1.154 +#define ucisclosepunct(cc) ucisprop(cc, UC_PE, 0) 1.155 +#define ucisinitialpunct(cc) ucisprop(cc, 0, UC_PI) 1.156 +#define ucisfinalpunct(cc) ucisprop(cc, 0, UC_PF) 1.157 + 1.158 +#define uciscomposite(cc) ucisprop(cc, 0, UC_CM) 1.159 +#define ucishex(cc) ucisprop(cc, 0, UC_HD) 1.160 +#define ucisquote(cc) ucisprop(cc, 0, UC_QM) 1.161 +#define ucissymmetric(cc) ucisprop(cc, 0, UC_SY) 1.162 +#define ucismirroring(cc) ucisprop(cc, 0, UC_MR) 1.163 +#define ucisnonbreaking(cc) ucisprop(cc, 0, UC_NB) 1.164 + 1.165 +/* 1.166 + * Directionality macros. 1.167 + */ 1.168 +#define ucisrtl(cc) ucisprop(cc, UC_R, 0) 1.169 +#define ucisltr(cc) ucisprop(cc, UC_L, 0) 1.170 +#define ucisstrong(cc) ucisprop(cc, UC_L|UC_R, 0) 1.171 +#define ucisweak(cc) ucisprop(cc, UC_EN|UC_ES, UC_ET|UC_AN|UC_CS) 1.172 +#define ucisneutral(cc) ucisprop(cc, 0, UC_B|UC_S|UC_WS|UC_ON) 1.173 +#define ucisseparator(cc) ucisprop(cc, 0, UC_B|UC_S) 1.174 + 1.175 +/* 1.176 + * Other macros inspired by John Cowan. 1.177 + */ 1.178 +#define ucismark(cc) ucisprop(cc, UC_MN|UC_MC|UC_ME, 0) 1.179 +#define ucismodif(cc) ucisprop(cc, UC_LM, 0) 1.180 +#define ucisletnum(cc) ucisprop(cc, UC_NL, 0) 1.181 +#define ucisconnect(cc) ucisprop(cc, UC_PC, 0) 1.182 +#define ucisdash(cc) ucisprop(cc, UC_PD, 0) 1.183 +#define ucismath(cc) ucisprop(cc, UC_SM, 0) 1.184 +#define uciscurrency(cc) ucisprop(cc, UC_SC, 0) 1.185 +#define ucismodifsymbol(cc) ucisprop(cc, UC_SK, 0) 1.186 +#define ucisnsmark(cc) ucisprop(cc, UC_MN, 0) 1.187 +#define ucisspmark(cc) ucisprop(cc, UC_MC, 0) 1.188 +#define ucisenclosing(cc) ucisprop(cc, UC_ME, 0) 1.189 +#define ucisprivate(cc) ucisprop(cc, UC_CO, 0) 1.190 +#define ucissurrogate(cc) ucisprop(cc, UC_OS, 0) 1.191 +#define ucislsep(cc) ucisprop(cc, UC_ZL, 0) 1.192 +#define ucispsep(cc) ucisprop(cc, UC_ZP, 0) 1.193 + 1.194 +#define ucisidentstart(cc) ucisprop(cc, UC_LU|UC_LL|UC_LT|UC_LO|UC_NL, 0) 1.195 +#define ucisidentpart(cc) ucisprop(cc, UC_LU|UC_LL|UC_LT|UC_LO|UC_NL|\ 1.196 + UC_MN|UC_MC|UC_ND|UC_PC|UC_CF, 0) 1.197 + 1.198 +#define ucisdefined(cc) ucisprop(cc, 0, UC_CP) 1.199 +#define ucisundefined(cc) !ucisprop(cc, 0, UC_CP) 1.200 + 1.201 +/* 1.202 + * Other miscellaneous character property macros. 1.203 + */ 1.204 +#define ucishan(cc) (((cc) >= 0x4e00 && (cc) <= 0x9fff) ||\ 1.205 + ((cc) >= 0xf900 && (cc) <= 0xfaff)) 1.206 +#define ucishangul(cc) ((cc) >= 0xac00 && (cc) <= 0xd7ff) 1.207 + 1.208 +/************************************************************************** 1.209 + * 1.210 + * Functions for case conversion. 1.211 + * 1.212 + **************************************************************************/ 1.213 + 1.214 +extern unsigned long uctoupper __((unsigned long code)); 1.215 +extern unsigned long uctolower __((unsigned long code)); 1.216 +extern unsigned long uctotitle __((unsigned long code)); 1.217 + 1.218 +/************************************************************************** 1.219 + * 1.220 + * Functions for getting decompositions. 1.221 + * 1.222 + **************************************************************************/ 1.223 + 1.224 +/* 1.225 + * This routine determines if the code has a decomposition. If it returns 0, 1.226 + * there is no decomposition. Any other value indicates a decomposition was 1.227 + * returned. 1.228 + */ 1.229 +extern int ucdecomp __((unsigned long code, unsigned long *num, 1.230 + 1.231 + unsigned long **decomp)); 1.232 + 1.233 +/* 1.234 + * If the code is a Hangul syllable, this routine decomposes it into the array 1.235 + * passed. The array size should be at least 3. 1.236 + */ 1.237 +extern int ucdecomp_hangul __((unsigned long code, unsigned long *num, 1.238 + unsigned long decomp[])); 1.239 + 1.240 +/************************************************************************** 1.241 + * 1.242 + * Functions for getting combining classes. 1.243 + * 1.244 + **************************************************************************/ 1.245 + 1.246 +/* 1.247 + * This will return the combining class for a character to be used with the 1.248 + * Canonical Ordering algorithm. 1.249 + */ 1.250 +extern unsigned long uccombining_class __((unsigned long code)); 1.251 + 1.252 +/************************************************************************** 1.253 + * 1.254 + * Functions for getting numbers and digits. 1.255 + * 1.256 + **************************************************************************/ 1.257 + 1.258 +struct ucnumber { 1.259 + int numerator; 1.260 + int denominator; 1.261 +}; 1.262 + 1.263 +extern int ucnumber_lookup __((unsigned long code, struct ucnumber *num)); 1.264 +extern int ucdigit_lookup __((unsigned long code, int *digit)); 1.265 + 1.266 +/* 1.267 + * For compatibility with John Cowan's "uctype" package. 1.268 + */ 1.269 +extern struct ucnumber ucgetnumber __((unsigned long code)); 1.270 +extern int ucgetdigit __((unsigned long code)); 1.271 + 1.272 +/************************************************************************** 1.273 + * 1.274 + * Functions library initialization and cleanup. 1.275 + * 1.276 + **************************************************************************/ 1.277 + 1.278 +/* 1.279 + * Macros for specifying the data tables to be loaded for ucdata_load(). 1.280 + */ 1.281 +#define UCDATA_CASE 0x01 1.282 +#define UCDATA_CTYPE 0x02 1.283 +#define UCDATA_DECOMP 0x04 1.284 +#define UCDATA_CMBCL 0x08 1.285 +#define UCDATA_NUM 0x10 1.286 + 1.287 +#define UCDATA_ALL (UCDATA_CASE|UCDATA_CTYPE|UCDATA_DECOMP|\ 1.288 + UCDATA_CMBCL|UCDATA_NUM) 1.289 + 1.290 +/* 1.291 + * Functions to load, unload, and reload specific data files. 1.292 + */ 1.293 +extern void ucdata_load __((char *paths, int mask)); 1.294 +extern void ucdata_unload __((int mask)); 1.295 +extern void ucdata_reload __((char *paths, int mask)); 1.296 + 1.297 +/* 1.298 + * Deprecated functions, now just compatibility macros. 1.299 + */ 1.300 +#define ucdata_setup(p) ucdata_load(p, UCDATA_ALL) 1.301 +#define ucdata_cleanup() ucdata_unload(UCDATA_ALL) 1.302 + 1.303 +#undef __ 1.304 + 1.305 +#ifdef __cplusplus 1.306 +} 1.307 +#endif 1.308 + 1.309 +#endif /* _h_ucdata */