Back to index

lightning-sunbird  0.9+nobinonly
ucdata.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 1996, 1997, 1998 Computing Research Labs,
00003  * New Mexico State University
00004  *
00005  * Permission is hereby granted, free of charge, to any person obtaining a
00006  * copy of this software and associated documentation files (the "Software"),
00007  * to deal in the Software without restriction, including without limitation
00008  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00009  * and/or sell copies of the Software, and to permit persons to whom the
00010  * Software is furnished to do so, subject to the following conditions:
00011  *
00012  * The above copyright notice and this permission notice shall be included in
00013  * all copies or substantial portions of the Software.
00014  *
00015  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00016  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00017  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
00018  * THE COMPUTING RESEARCH LAB OR NEW MEXICO STATE UNIVERSITY BE LIABLE FOR ANY
00019  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
00020  * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
00021  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00022  */
00023 #ifndef _h_ucdata
00024 #define _h_ucdata
00025 
00026 /*
00027  * $Id: ucdata.h,v 1.1 1999/01/08 00:19:12 ftang%netscape.com Exp $
00028  */
00029 
00030 #ifdef __cplusplus
00031 extern "C" {
00032 #endif
00033 
00034 #undef __
00035 #ifdef __STDC__
00036 #define __(x) x
00037 #else
00038 #define __(x) ()
00039 #endif
00040 
00041 #define UCDATA_VERSION "1.9"
00042 
00043 /**************************************************************************
00044  *
00045  * Masks and macros for character properties.
00046  *
00047  **************************************************************************/
00048 
00049 /*
00050  * Values that can appear in the `mask1' parameter of the ucisprop()
00051  * function.
00052  */
00053 #define UC_MN 0x00000001 /* Mark, Non-Spacing          */
00054 #define UC_MC 0x00000002 /* Mark, Spacing Combining    */
00055 #define UC_ME 0x00000004 /* Mark, Enclosing            */
00056 #define UC_ND 0x00000008 /* Number, Decimal Digit      */
00057 #define UC_NL 0x00000010 /* Number, Letter             */
00058 #define UC_NO 0x00000020 /* Number, Other              */
00059 #define UC_ZS 0x00000040 /* Separator, Space           */
00060 #define UC_ZL 0x00000080 /* Separator, Line            */
00061 #define UC_ZP 0x00000100 /* Separator, Paragraph       */
00062 #define UC_CC 0x00000200 /* Other, Control             */
00063 #define UC_CF 0x00000400 /* Other, Format              */
00064 #define UC_OS 0x00000800 /* Other, Surrogate           */
00065 #define UC_CO 0x00001000 /* Other, Private Use         */
00066 #define UC_CN 0x00002000 /* Other, Not Assigned        */
00067 #define UC_LU 0x00004000 /* Letter, Uppercase          */
00068 #define UC_LL 0x00008000 /* Letter, Lowercase          */
00069 #define UC_LT 0x00010000 /* Letter, Titlecase          */
00070 #define UC_LM 0x00020000 /* Letter, Modifier           */
00071 #define UC_LO 0x00040000 /* Letter, Other              */
00072 #define UC_PC 0x00080000 /* Punctuation, Connector     */
00073 #define UC_PD 0x00100000 /* Punctuation, Dash          */
00074 #define UC_PS 0x00200000 /* Punctuation, Open          */
00075 #define UC_PE 0x00400000 /* Punctuation, Close         */
00076 #define UC_PO 0x00800000 /* Punctuation, Other         */
00077 #define UC_SM 0x01000000 /* Symbol, Math               */
00078 #define UC_SC 0x02000000 /* Symbol, Currency           */
00079 #define UC_SK 0x04000000 /* Symbol, Modifier           */
00080 #define UC_SO 0x08000000 /* Symbol, Other              */
00081 #define UC_L  0x10000000 /* Left-To-Right              */
00082 #define UC_R  0x20000000 /* Right-To-Left              */
00083 #define UC_EN 0x40000000 /* European Number            */
00084 #define UC_ES 0x80000000 /* European Number Separator  */
00085 
00086 /*
00087  * Values that can appear in the `mask2' parameter of the ucisprop()
00088  * function.
00089  */
00090 #define UC_ET 0x00000001 /* European Number Terminator */
00091 #define UC_AN 0x00000002 /* Arabic Number              */
00092 #define UC_CS 0x00000004 /* Common Number Separator    */
00093 #define UC_B  0x00000008 /* Block Separator            */
00094 #define UC_S  0x00000010 /* Segment Separator          */
00095 #define UC_WS 0x00000020 /* Whitespace                 */
00096 #define UC_ON 0x00000040 /* Other Neutrals             */
00097 /*
00098  * Implementation specific character properties.
00099  */
00100 #define UC_CM 0x00000080 /* Composite                  */
00101 #define UC_NB 0x00000100 /* Non-Breaking               */
00102 #define UC_SY 0x00000200 /* Symmetric                  */
00103 #define UC_HD 0x00000400 /* Hex Digit                  */
00104 #define UC_QM 0x00000800 /* Quote Mark                 */
00105 #define UC_MR 0x00001000 /* Mirroring                  */
00106 #define UC_SS 0x00002000 /* Space, other               */
00107 
00108 #define UC_CP 0x00004000 /* Defined                    */
00109 
00110 /*
00111  * Added for UnicodeData-2.1.3.
00112  */
00113 #define UC_PI 0x00008000 /* Punctuation, Initial       */
00114 #define UC_PF 0x00010000 /* Punctuation, Final         */
00115 
00116 /*
00117  * This is the primary function for testing to see if a character has some set
00118  * of properties.  The macros that test for various character properties all
00119  * call this function with some set of masks.
00120  */
00121 extern int ucisprop __((unsigned long code, unsigned long mask1,
00122                         unsigned long mask2));
00123 
00124 #define ucisalpha(cc) ucisprop(cc, UC_LU|UC_LL|UC_LM|UC_LO|UC_LT, 0)
00125 #define ucisdigit(cc) ucisprop(cc, UC_ND, 0)
00126 #define ucisalnum(cc) ucisprop(cc, UC_LU|UC_LL|UC_LM|UC_LO|UC_LT|UC_ND, 0)
00127 #define uciscntrl(cc) ucisprop(cc, UC_CC|UC_CF, 0)
00128 #define ucisspace(cc) ucisprop(cc, UC_ZS|UC_SS, 0)
00129 #define ucisblank(cc) ucisprop(cc, UC_ZS, 0)
00130 #define ucispunct(cc) ucisprop(cc, UC_PD|UC_PS|UC_PE|UC_PO, UC_PI|UC_PF)
00131 #define ucisgraph(cc) ucisprop(cc, UC_MN|UC_MC|UC_ME|UC_ND|UC_NL|UC_NO|\
00132                                UC_LU|UC_LL|UC_LT|UC_LM|UC_LO|UC_PC|UC_PD|\
00133                                UC_PS|UC_PE|UC_PO|UC_SM|UC_SM|UC_SC|UC_SK|\
00134                                UC_SO, UC_PI|UC_PF)
00135 #define ucisprint(cc) ucisprop(cc, UC_MN|UC_MC|UC_ME|UC_ND|UC_NL|UC_NO|\
00136                                UC_LU|UC_LL|UC_LT|UC_LM|UC_LO|UC_PC|UC_PD|\
00137                                UC_PS|UC_PE|UC_PO|UC_SM|UC_SM|UC_SC|UC_SK|\
00138                                UC_SO|UC_ZS, UC_PI|UC_PF)
00139 #define ucisupper(cc) ucisprop(cc, UC_LU, 0)
00140 #define ucislower(cc) ucisprop(cc, UC_LL, 0)
00141 #define ucistitle(cc) ucisprop(cc, UC_LT, 0)
00142 #define ucisxdigit(cc) ucisprop(cc, 0, UC_HD)
00143 
00144 #define ucisisocntrl(cc) ucisprop(cc, UC_CC, 0)
00145 #define ucisfmtcntrl(cc) ucisprop(cc, UC_CF, 0)
00146 
00147 #define ucissymbol(cc) ucisprop(cc, UC_SM|UC_SC|UC_SO|UC_SK, 0)
00148 #define ucisnumber(cc) ucisprop(cc, UC_ND|UC_NO|UC_NL, 0)
00149 #define ucisnonspacing(cc) ucisprop(cc, UC_MN, 0)
00150 #define ucisopenpunct(cc) ucisprop(cc, UC_PS, 0)
00151 #define ucisclosepunct(cc) ucisprop(cc, UC_PE, 0)
00152 #define ucisinitialpunct(cc) ucisprop(cc, 0, UC_PI)
00153 #define ucisfinalpunct(cc) ucisprop(cc, 0, UC_PF)
00154 
00155 #define uciscomposite(cc) ucisprop(cc, 0, UC_CM)
00156 #define ucishex(cc) ucisprop(cc, 0, UC_HD)
00157 #define ucisquote(cc) ucisprop(cc, 0, UC_QM)
00158 #define ucissymmetric(cc) ucisprop(cc, 0, UC_SY)
00159 #define ucismirroring(cc) ucisprop(cc, 0, UC_MR)
00160 #define ucisnonbreaking(cc) ucisprop(cc, 0, UC_NB)
00161 
00162 /*
00163  * Directionality macros.
00164  */
00165 #define ucisrtl(cc) ucisprop(cc, UC_R, 0)
00166 #define ucisltr(cc) ucisprop(cc, UC_L, 0)
00167 #define ucisstrong(cc) ucisprop(cc, UC_L|UC_R, 0)
00168 #define ucisweak(cc) ucisprop(cc, UC_EN|UC_ES, UC_ET|UC_AN|UC_CS)
00169 #define ucisneutral(cc) ucisprop(cc, 0, UC_B|UC_S|UC_WS|UC_ON)
00170 #define ucisseparator(cc) ucisprop(cc, 0, UC_B|UC_S)
00171 
00172 /*
00173  * Other macros inspired by John Cowan.
00174  */
00175 #define ucismark(cc) ucisprop(cc, UC_MN|UC_MC|UC_ME, 0)
00176 #define ucismodif(cc) ucisprop(cc, UC_LM, 0)
00177 #define ucisletnum(cc) ucisprop(cc, UC_NL, 0)
00178 #define ucisconnect(cc) ucisprop(cc, UC_PC, 0)
00179 #define ucisdash(cc) ucisprop(cc, UC_PD, 0)
00180 #define ucismath(cc) ucisprop(cc, UC_SM, 0)
00181 #define uciscurrency(cc) ucisprop(cc, UC_SC, 0)
00182 #define ucismodifsymbol(cc) ucisprop(cc, UC_SK, 0)
00183 #define ucisnsmark(cc) ucisprop(cc, UC_MN, 0)
00184 #define ucisspmark(cc) ucisprop(cc, UC_MC, 0)
00185 #define ucisenclosing(cc) ucisprop(cc, UC_ME, 0)
00186 #define ucisprivate(cc) ucisprop(cc, UC_CO, 0)
00187 #define ucissurrogate(cc) ucisprop(cc, UC_OS, 0)
00188 #define ucislsep(cc) ucisprop(cc, UC_ZL, 0)
00189 #define ucispsep(cc) ucisprop(cc, UC_ZP, 0)
00190 
00191 #define ucisidentstart(cc) ucisprop(cc, UC_LU|UC_LL|UC_LT|UC_LO|UC_NL, 0)
00192 #define ucisidentpart(cc) ucisprop(cc, UC_LU|UC_LL|UC_LT|UC_LO|UC_NL|\
00193                                    UC_MN|UC_MC|UC_ND|UC_PC|UC_CF, 0)
00194 
00195 #define ucisdefined(cc) ucisprop(cc, 0, UC_CP)
00196 #define ucisundefined(cc) !ucisprop(cc, 0, UC_CP)
00197 
00198 /*
00199  * Other miscellaneous character property macros.
00200  */
00201 #define ucishan(cc) (((cc) >= 0x4e00 && (cc) <= 0x9fff) ||\
00202                      ((cc) >= 0xf900 && (cc) <= 0xfaff))
00203 #define ucishangul(cc) ((cc) >= 0xac00 && (cc) <= 0xd7ff)
00204 
00205 /**************************************************************************
00206  *
00207  * Functions for case conversion.
00208  *
00209  **************************************************************************/
00210 
00211 extern unsigned long uctoupper __((unsigned long code));
00212 extern unsigned long uctolower __((unsigned long code));
00213 extern unsigned long uctotitle __((unsigned long code));
00214 
00215 /**************************************************************************
00216  *
00217  * Functions for getting decompositions.
00218  *
00219  **************************************************************************/
00220 
00221 /*
00222  * This routine determines if the code has a decomposition.  If it returns 0,
00223  * there is no decomposition.  Any other value indicates a decomposition was
00224  * returned.
00225  */
00226 extern int ucdecomp __((unsigned long code, unsigned long *num,
00227 
00228                         unsigned long **decomp));
00229 
00230 /*
00231  * If the code is a Hangul syllable, this routine decomposes it into the array
00232  * passed.  The array size should be at least 3.
00233  */
00234 extern int ucdecomp_hangul __((unsigned long code, unsigned long *num,
00235                                unsigned long decomp[]));
00236 
00237 /**************************************************************************
00238  *
00239  * Functions for getting combining classes.
00240  *
00241  **************************************************************************/
00242 
00243 /*
00244  * This will return the combining class for a character to be used with the
00245  * Canonical Ordering algorithm.
00246  */
00247 extern unsigned long uccombining_class __((unsigned long code));
00248 
00249 /**************************************************************************
00250  *
00251  * Functions for getting numbers and digits.
00252  *
00253  **************************************************************************/
00254 
00255 struct ucnumber {
00256     int numerator;
00257     int denominator;
00258 };
00259 
00260 extern int ucnumber_lookup __((unsigned long code, struct ucnumber *num));
00261 extern int ucdigit_lookup __((unsigned long code, int *digit));
00262 
00263 /*
00264  * For compatibility with John Cowan's "uctype" package.
00265  */
00266 extern struct ucnumber ucgetnumber __((unsigned long code));
00267 extern int ucgetdigit __((unsigned long code));
00268 
00269 /**************************************************************************
00270  *
00271  * Functions library initialization and cleanup.
00272  *
00273  **************************************************************************/
00274 
00275 /*
00276  * Macros for specifying the data tables to be loaded for ucdata_load().
00277  */
00278 #define UCDATA_CASE   0x01
00279 #define UCDATA_CTYPE  0x02
00280 #define UCDATA_DECOMP 0x04
00281 #define UCDATA_CMBCL  0x08
00282 #define UCDATA_NUM    0x10
00283 
00284 #define UCDATA_ALL (UCDATA_CASE|UCDATA_CTYPE|UCDATA_DECOMP|\
00285                     UCDATA_CMBCL|UCDATA_NUM)
00286 
00287 /*
00288  * Functions to load, unload, and reload specific data files.
00289  */
00290 extern void ucdata_load __((char *paths, int mask));
00291 extern void ucdata_unload __((int mask));
00292 extern void ucdata_reload __((char *paths, int mask));
00293 
00294 /*
00295  * Deprecated functions, now just compatibility macros.
00296  */
00297 #define ucdata_setup(p) ucdata_load(p, UCDATA_ALL)
00298 #define ucdata_cleanup() ucdata_unload(UCDATA_ALL)
00299 
00300 #undef __
00301 
00302 #ifdef __cplusplus
00303 }
00304 #endif
00305 
00306 #endif /* _h_ucdata */