New module 'unictype/joiningtype-longname'.
[gnulib.git] / lib / unictype.in.h
1 /* Unicode character classification and properties.
2    Copyright (C) 2002, 2005-2011 Free Software Foundation, Inc.
3
4    This program is free software: you can redistribute it and/or modify it
5    under the terms of the GNU Lesser General Public License as published
6    by the Free Software Foundation; either version 3 of the License, or
7    (at your option) any later version.
8
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    Lesser General Public License for more details.
13
14    You should have received a copy of the GNU Lesser General Public License
15    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
16
17 #ifndef _UNICTYPE_H
18 #define _UNICTYPE_H
19
20 #include "unitypes.h"
21
22 /* Get bool.  */
23 #include <stdbool.h>
24
25 /* Get size_t.  */
26 #include <stddef.h>
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
32 /* ========================================================================= */
33
34 /* Field 1 of Unicode Character Database: Character name.
35    See "uniname.h".  */
36
37 /* ========================================================================= */
38
39 /* Field 2 of Unicode Character Database: General category.  */
40
41 /* Data type denoting a General category value.  This is not just a bitmask,
42    but rather a bitmask and a pointer to the lookup table, so that programs
43    that use only the predefined bitmasks (i.e. don't combine bitmasks with &
44    and |) don't have a link-time dependency towards the big general table.  */
45 typedef struct
46 {
47   uint32_t bitmask : 31;
48   /*bool*/ unsigned int generic : 1;
49   union
50   {
51     const void *table;                               /* when generic is 0 */
52     bool (*lookup_fn) (ucs4_t uc, uint32_t bitmask); /* when generic is 1 */
53   } lookup;
54 }
55 uc_general_category_t;
56
57 /* Bits and bit masks denoting General category values.  UnicodeData-3.2.0.html
58    says a 32-bit integer will always suffice to represent them.
59    These bit masks can only be used with the uc_is_general_category_withtable
60    function.  */
61 enum
62 {
63   UC_CATEGORY_MASK_L  = 0x0000001f,
64   UC_CATEGORY_MASK_LC = 0x00000007,
65   UC_CATEGORY_MASK_Lu = 0x00000001,
66   UC_CATEGORY_MASK_Ll = 0x00000002,
67   UC_CATEGORY_MASK_Lt = 0x00000004,
68   UC_CATEGORY_MASK_Lm = 0x00000008,
69   UC_CATEGORY_MASK_Lo = 0x00000010,
70   UC_CATEGORY_MASK_M  = 0x000000e0,
71   UC_CATEGORY_MASK_Mn = 0x00000020,
72   UC_CATEGORY_MASK_Mc = 0x00000040,
73   UC_CATEGORY_MASK_Me = 0x00000080,
74   UC_CATEGORY_MASK_N  = 0x00000700,
75   UC_CATEGORY_MASK_Nd = 0x00000100,
76   UC_CATEGORY_MASK_Nl = 0x00000200,
77   UC_CATEGORY_MASK_No = 0x00000400,
78   UC_CATEGORY_MASK_P  = 0x0003f800,
79   UC_CATEGORY_MASK_Pc = 0x00000800,
80   UC_CATEGORY_MASK_Pd = 0x00001000,
81   UC_CATEGORY_MASK_Ps = 0x00002000,
82   UC_CATEGORY_MASK_Pe = 0x00004000,
83   UC_CATEGORY_MASK_Pi = 0x00008000,
84   UC_CATEGORY_MASK_Pf = 0x00010000,
85   UC_CATEGORY_MASK_Po = 0x00020000,
86   UC_CATEGORY_MASK_S  = 0x003c0000,
87   UC_CATEGORY_MASK_Sm = 0x00040000,
88   UC_CATEGORY_MASK_Sc = 0x00080000,
89   UC_CATEGORY_MASK_Sk = 0x00100000,
90   UC_CATEGORY_MASK_So = 0x00200000,
91   UC_CATEGORY_MASK_Z  = 0x01c00000,
92   UC_CATEGORY_MASK_Zs = 0x00400000,
93   UC_CATEGORY_MASK_Zl = 0x00800000,
94   UC_CATEGORY_MASK_Zp = 0x01000000,
95   UC_CATEGORY_MASK_C  = 0x3e000000,
96   UC_CATEGORY_MASK_Cc = 0x02000000,
97   UC_CATEGORY_MASK_Cf = 0x04000000,
98   UC_CATEGORY_MASK_Cs = 0x08000000,
99   UC_CATEGORY_MASK_Co = 0x10000000,
100   UC_CATEGORY_MASK_Cn = 0x20000000
101 };
102
103 /* Predefined General category values.  */
104 extern const uc_general_category_t UC_CATEGORY_L;
105 extern const uc_general_category_t UC_CATEGORY_LC;
106 extern const uc_general_category_t UC_CATEGORY_Lu;
107 extern const uc_general_category_t UC_CATEGORY_Ll;
108 extern const uc_general_category_t UC_CATEGORY_Lt;
109 extern const uc_general_category_t UC_CATEGORY_Lm;
110 extern const uc_general_category_t UC_CATEGORY_Lo;
111 extern const uc_general_category_t UC_CATEGORY_M;
112 extern const uc_general_category_t UC_CATEGORY_Mn;
113 extern const uc_general_category_t UC_CATEGORY_Mc;
114 extern const uc_general_category_t UC_CATEGORY_Me;
115 extern const uc_general_category_t UC_CATEGORY_N;
116 extern const uc_general_category_t UC_CATEGORY_Nd;
117 extern const uc_general_category_t UC_CATEGORY_Nl;
118 extern const uc_general_category_t UC_CATEGORY_No;
119 extern const uc_general_category_t UC_CATEGORY_P;
120 extern const uc_general_category_t UC_CATEGORY_Pc;
121 extern const uc_general_category_t UC_CATEGORY_Pd;
122 extern const uc_general_category_t UC_CATEGORY_Ps;
123 extern const uc_general_category_t UC_CATEGORY_Pe;
124 extern const uc_general_category_t UC_CATEGORY_Pi;
125 extern const uc_general_category_t UC_CATEGORY_Pf;
126 extern const uc_general_category_t UC_CATEGORY_Po;
127 extern const uc_general_category_t UC_CATEGORY_S;
128 extern const uc_general_category_t UC_CATEGORY_Sm;
129 extern const uc_general_category_t UC_CATEGORY_Sc;
130 extern const uc_general_category_t UC_CATEGORY_Sk;
131 extern const uc_general_category_t UC_CATEGORY_So;
132 extern const uc_general_category_t UC_CATEGORY_Z;
133 extern const uc_general_category_t UC_CATEGORY_Zs;
134 extern const uc_general_category_t UC_CATEGORY_Zl;
135 extern const uc_general_category_t UC_CATEGORY_Zp;
136 extern const uc_general_category_t UC_CATEGORY_C;
137 extern const uc_general_category_t UC_CATEGORY_Cc;
138 extern const uc_general_category_t UC_CATEGORY_Cf;
139 extern const uc_general_category_t UC_CATEGORY_Cs;
140 extern const uc_general_category_t UC_CATEGORY_Co;
141 extern const uc_general_category_t UC_CATEGORY_Cn;
142 /* Non-public.  */
143 extern const uc_general_category_t _UC_CATEGORY_NONE;
144
145 /* Alias names for predefined General category values.  */
146 #define UC_LETTER                    UC_CATEGORY_L
147 #define UC_CASED_LETTER              UC_CATEGORY_LC
148 #define UC_UPPERCASE_LETTER          UC_CATEGORY_Lu
149 #define UC_LOWERCASE_LETTER          UC_CATEGORY_Ll
150 #define UC_TITLECASE_LETTER          UC_CATEGORY_Lt
151 #define UC_MODIFIER_LETTER           UC_CATEGORY_Lm
152 #define UC_OTHER_LETTER              UC_CATEGORY_Lo
153 #define UC_MARK                      UC_CATEGORY_M
154 #define UC_NON_SPACING_MARK          UC_CATEGORY_Mn
155 #define UC_COMBINING_SPACING_MARK    UC_CATEGORY_Mc
156 #define UC_ENCLOSING_MARK            UC_CATEGORY_Me
157 #define UC_NUMBER                    UC_CATEGORY_N
158 #define UC_DECIMAL_DIGIT_NUMBER      UC_CATEGORY_Nd
159 #define UC_LETTER_NUMBER             UC_CATEGORY_Nl
160 #define UC_OTHER_NUMBER              UC_CATEGORY_No
161 #define UC_PUNCTUATION               UC_CATEGORY_P
162 #define UC_CONNECTOR_PUNCTUATION     UC_CATEGORY_Pc
163 #define UC_DASH_PUNCTUATION          UC_CATEGORY_Pd
164 #define UC_OPEN_PUNCTUATION          UC_CATEGORY_Ps /* a.k.a. UC_START_PUNCTUATION */
165 #define UC_CLOSE_PUNCTUATION         UC_CATEGORY_Pe /* a.k.a. UC_END_PUNCTUATION */
166 #define UC_INITIAL_QUOTE_PUNCTUATION UC_CATEGORY_Pi
167 #define UC_FINAL_QUOTE_PUNCTUATION   UC_CATEGORY_Pf
168 #define UC_OTHER_PUNCTUATION         UC_CATEGORY_Po
169 #define UC_SYMBOL                    UC_CATEGORY_S
170 #define UC_MATH_SYMBOL               UC_CATEGORY_Sm
171 #define UC_CURRENCY_SYMBOL           UC_CATEGORY_Sc
172 #define UC_MODIFIER_SYMBOL           UC_CATEGORY_Sk
173 #define UC_OTHER_SYMBOL              UC_CATEGORY_So
174 #define UC_SEPARATOR                 UC_CATEGORY_Z
175 #define UC_SPACE_SEPARATOR           UC_CATEGORY_Zs
176 #define UC_LINE_SEPARATOR            UC_CATEGORY_Zl
177 #define UC_PARAGRAPH_SEPARATOR       UC_CATEGORY_Zp
178 #define UC_OTHER                     UC_CATEGORY_C
179 #define UC_CONTROL                   UC_CATEGORY_Cc
180 #define UC_FORMAT                    UC_CATEGORY_Cf
181 #define UC_SURROGATE                 UC_CATEGORY_Cs /* all of them are invalid characters */
182 #define UC_PRIVATE_USE               UC_CATEGORY_Co
183 #define UC_UNASSIGNED                UC_CATEGORY_Cn /* some of them are invalid characters */
184
185 /* Return the union of two general categories.
186    This corresponds to the unions of the two sets of characters.  */
187 extern uc_general_category_t
188        uc_general_category_or (uc_general_category_t category1,
189                                uc_general_category_t category2);
190
191 /* Return the intersection of two general categories as bit masks.
192    This *does*not* correspond to the intersection of the two sets of
193    characters.  */
194 extern uc_general_category_t
195        uc_general_category_and (uc_general_category_t category1,
196                                 uc_general_category_t category2);
197
198 /* Return the intersection of a general category with the complement of a
199    second general category, as bit masks.
200    This *does*not* correspond to the intersection with complement, when
201    viewing the categories as sets of characters.  */
202 extern uc_general_category_t
203        uc_general_category_and_not (uc_general_category_t category1,
204                                     uc_general_category_t category2);
205
206 /* Return the name of a general category.  */
207 extern const char *
208        uc_general_category_name (uc_general_category_t category);
209
210 /* Return the long name of a general category.  */
211 extern const char *
212        uc_general_category_long_name (uc_general_category_t category);
213
214 /* Return the general category given by name, e.g. "Lu", or by long name,
215    e.g. "Uppercase Letter".  */
216 extern uc_general_category_t
217        uc_general_category_byname (const char *category_name);
218
219 /* Return the general category of a Unicode character.  */
220 extern uc_general_category_t
221        uc_general_category (ucs4_t uc);
222
223 /* Test whether a Unicode character belongs to a given category.
224    The CATEGORY argument can be the combination of several predefined
225    general categories.  */
226 extern bool
227        uc_is_general_category (ucs4_t uc, uc_general_category_t category);
228 /* Likewise.  This function uses a big table comprising all categories.  */
229 extern bool
230        uc_is_general_category_withtable (ucs4_t uc, uint32_t bitmask);
231
232 /* ========================================================================= */
233
234 /* Field 3 of Unicode Character Database: Canonical combining class.  */
235
236 /* The possible results of uc_combining_class (0..255) are described in
237    UCD.html.  The list here is not definitive; more values can be added
238    in future versions.  */
239 enum
240 {
241   UC_CCC_NR   =   0, /* Not Reordered */
242   UC_CCC_OV   =   1, /* Overlay */
243   UC_CCC_NK   =   7, /* Nukta */
244   UC_CCC_KV   =   8, /* Kana Voicing */
245   UC_CCC_VR   =   9, /* Virama */
246   UC_CCC_ATBL = 200, /* Attached Below Left */
247   UC_CCC_ATB  = 202, /* Attached Below */
248   UC_CCC_ATA  = 214, /* Attached Above */
249   UC_CCC_ATAR = 216, /* Attached Above Right */
250   UC_CCC_BL   = 218, /* Below Left */
251   UC_CCC_B    = 220, /* Below */
252   UC_CCC_BR   = 222, /* Below Right */
253   UC_CCC_L    = 224, /* Left */
254   UC_CCC_R    = 226, /* Right */
255   UC_CCC_AL   = 228, /* Above Left */
256   UC_CCC_A    = 230, /* Above */
257   UC_CCC_AR   = 232, /* Above Right */
258   UC_CCC_DB   = 233, /* Double Below */
259   UC_CCC_DA   = 234, /* Double Above */
260   UC_CCC_IS   = 240  /* Iota Subscript */
261 };
262
263 /* Return the canonical combining class of a Unicode character.  */
264 extern int
265        uc_combining_class (ucs4_t uc);
266
267 /* Return the name of a canonical combining class.  */
268 extern const char *
269        uc_combining_class_name (int ccc);
270
271 /* Return the long name of a canonical combining class.  */
272 extern const char *
273        uc_combining_class_long_name (int ccc);
274
275 /* Return the canonical combining class given by name, e.g. "BL", or by long
276    name, e.g. "Below Left".  */
277 extern int
278        uc_combining_class_byname (const char *ccc_name);
279
280 /* ========================================================================= */
281
282 /* Field 4 of Unicode Character Database: Bidi class.
283    Before Unicode 4.0, this field was called "Bidirectional category".  */
284
285 enum
286 {
287   UC_BIDI_L,   /* Left-to-Right */
288   UC_BIDI_LRE, /* Left-to-Right Embedding */
289   UC_BIDI_LRO, /* Left-to-Right Override */
290   UC_BIDI_R,   /* Right-to-Left */
291   UC_BIDI_AL,  /* Right-to-Left Arabic */
292   UC_BIDI_RLE, /* Right-to-Left Embedding */
293   UC_BIDI_RLO, /* Right-to-Left Override */
294   UC_BIDI_PDF, /* Pop Directional Format */
295   UC_BIDI_EN,  /* European Number */
296   UC_BIDI_ES,  /* European Number Separator */
297   UC_BIDI_ET,  /* European Number Terminator */
298   UC_BIDI_AN,  /* Arabic Number */
299   UC_BIDI_CS,  /* Common Number Separator */
300   UC_BIDI_NSM, /* Non-Spacing Mark */
301   UC_BIDI_BN,  /* Boundary Neutral */
302   UC_BIDI_B,   /* Paragraph Separator */
303   UC_BIDI_S,   /* Segment Separator */
304   UC_BIDI_WS,  /* Whitespace */
305   UC_BIDI_ON   /* Other Neutral */
306 };
307
308 /* Return the name of a bidi class.  */
309 extern const char *
310        uc_bidi_class_name (int bidi_class);
311 /* Same; obsolete function name.  */
312 extern const char *
313        uc_bidi_category_name (int category);
314
315 /* Return the long name of a bidi class.  */
316 extern const char *
317        uc_bidi_class_long_name (int bidi_class);
318
319 /* Return the bidi class given by name, e.g. "LRE", or by long name, e.g.
320    "Left-to-Right Embedding".  */
321 extern int
322        uc_bidi_class_byname (const char *bidi_class_name);
323 /* Same; obsolete function name.  */
324 extern int
325        uc_bidi_category_byname (const char *category_name);
326
327 /* Return the bidi class of a Unicode character.  */
328 extern int
329        uc_bidi_class (ucs4_t uc);
330 /* Same; obsolete function name.  */
331 extern int
332        uc_bidi_category (ucs4_t uc);
333
334 /* Test whether a Unicode character belongs to a given bidi class.  */
335 extern bool
336        uc_is_bidi_class (ucs4_t uc, int bidi_class);
337 /* Same; obsolete function name.  */
338 extern bool
339        uc_is_bidi_category (ucs4_t uc, int category);
340
341 /* ========================================================================= */
342
343 /* Field 5 of Unicode Character Database: Character decomposition mapping.
344    See "uninorm.h".  */
345
346 /* ========================================================================= */
347
348 /* Field 6 of Unicode Character Database: Decimal digit value.  */
349
350 /* Return the decimal digit value of a Unicode character.  */
351 extern int
352        uc_decimal_value (ucs4_t uc);
353
354 /* ========================================================================= */
355
356 /* Field 7 of Unicode Character Database: Digit value.  */
357
358 /* Return the digit value of a Unicode character.  */
359 extern int
360        uc_digit_value (ucs4_t uc);
361
362 /* ========================================================================= */
363
364 /* Field 8 of Unicode Character Database: Numeric value.  */
365
366 /* Return the numeric value of a Unicode character.  */
367 typedef struct
368 {
369   int numerator;
370   int denominator;
371 }
372 uc_fraction_t;
373 extern uc_fraction_t
374        uc_numeric_value (ucs4_t uc);
375
376 /* ========================================================================= */
377
378 /* Field 9 of Unicode Character Database: Mirrored.  */
379
380 /* Return the mirrored character of a Unicode character UC in *PUC.  */
381 extern bool
382        uc_mirror_char (ucs4_t uc, ucs4_t *puc);
383
384 /* ========================================================================= */
385
386 /* Field 10 of Unicode Character Database: Unicode 1.0 Name.
387    Not available in this library.  */
388
389 /* ========================================================================= */
390
391 /* Field 11 of Unicode Character Database: ISO 10646 comment.
392    Not available in this library.  */
393
394 /* ========================================================================= */
395
396 /* Field 12, 13, 14 of Unicode Character Database: Uppercase mapping,
397    lowercase mapping, titlecase mapping.  See "unicase.h".  */
398
399 /* ========================================================================= */
400
401 /* Field 2 of the file ArabicShaping.txt in the Unicode Character Database.  */
402
403 /* Possible joining types.  */
404 enum
405 {
406   UC_JOINING_TYPE_U, /* Non_Joining */
407   UC_JOINING_TYPE_T, /* Transparent */
408   UC_JOINING_TYPE_C, /* Join_Causing */
409   UC_JOINING_TYPE_L, /* Left_Joining */
410   UC_JOINING_TYPE_R, /* Right_Joining */
411   UC_JOINING_TYPE_D  /* Dual_Joining */
412 };
413
414 /* Return the name of a joining type.  */
415 extern const char *
416        uc_joining_type_name (int joining_type);
417
418 /* Return the long name of a joining type.  */
419 extern const char *
420        uc_joining_type_long_name (int joining_type);
421
422 /* Return the joining type given by name, e.g. "D".  */
423 extern int
424        uc_joining_type_byname (const char *joining_type_name);
425
426 /* Return the joining type of a Unicode character.  */
427 extern int
428        uc_joining_type (ucs4_t uc);
429
430 /* ========================================================================= */
431
432 /* Field 3 of the file ArabicShaping.txt in the Unicode Character Database.  */
433
434 /* Possible joining groups.
435    This enumeration may be extended in the future.  */
436 enum
437 {
438   UC_JOINING_GROUP_NONE,                  /* No_Joining_Group */
439   UC_JOINING_GROUP_AIN,                   /* Ain */
440   UC_JOINING_GROUP_ALAPH,                 /* Alaph */
441   UC_JOINING_GROUP_ALEF,                  /* Alef */
442   UC_JOINING_GROUP_BEH,                   /* Beh */
443   UC_JOINING_GROUP_BETH,                  /* Beth */
444   UC_JOINING_GROUP_BURUSHASKI_YEH_BARREE, /* Burushaski_Yeh_Barree */
445   UC_JOINING_GROUP_DAL,                   /* Dal */
446   UC_JOINING_GROUP_DALATH_RISH,           /* Dalath_Rish */
447   UC_JOINING_GROUP_E,                     /* E */
448   UC_JOINING_GROUP_FARSI_YEH,             /* Farsi_Yeh */
449   UC_JOINING_GROUP_FE,                    /* Fe */
450   UC_JOINING_GROUP_FEH,                   /* Feh */
451   UC_JOINING_GROUP_FINAL_SEMKATH,         /* Final_Semkath */
452   UC_JOINING_GROUP_GAF,                   /* Gaf */
453   UC_JOINING_GROUP_GAMAL,                 /* Gamal */
454   UC_JOINING_GROUP_HAH,                   /* Hah */
455   UC_JOINING_GROUP_HE,                    /* He */
456   UC_JOINING_GROUP_HEH,                   /* Heh */
457   UC_JOINING_GROUP_HEH_GOAL,              /* Heh_Goal */
458   UC_JOINING_GROUP_HETH,                  /* Heth */
459   UC_JOINING_GROUP_KAF,                   /* Kaf */
460   UC_JOINING_GROUP_KAPH,                  /* Kaph */
461   UC_JOINING_GROUP_KHAPH,                 /* Khaph */
462   UC_JOINING_GROUP_KNOTTED_HEH,           /* Knotted_Heh */
463   UC_JOINING_GROUP_LAM,                   /* Lam */
464   UC_JOINING_GROUP_LAMADH,                /* Lamadh */
465   UC_JOINING_GROUP_MEEM,                  /* Meem */
466   UC_JOINING_GROUP_MIM,                   /* Mim */
467   UC_JOINING_GROUP_NOON,                  /* Noon */
468   UC_JOINING_GROUP_NUN,                   /* Nun */
469   UC_JOINING_GROUP_NYA,                   /* Nya */
470   UC_JOINING_GROUP_PE,                    /* Pe */
471   UC_JOINING_GROUP_QAF,                   /* Qaf */
472   UC_JOINING_GROUP_QAPH,                  /* Qaph */
473   UC_JOINING_GROUP_REH,                   /* Reh */
474   UC_JOINING_GROUP_REVERSED_PE,           /* Reversed_Pe */
475   UC_JOINING_GROUP_SAD,                   /* Sad */
476   UC_JOINING_GROUP_SADHE,                 /* Sadhe */
477   UC_JOINING_GROUP_SEEN,                  /* Seen */
478   UC_JOINING_GROUP_SEMKATH,               /* Semkath */
479   UC_JOINING_GROUP_SHIN,                  /* Shin */
480   UC_JOINING_GROUP_SWASH_KAF,             /* Swash_Kaf */
481   UC_JOINING_GROUP_SYRIAC_WAW,            /* Syriac_Waw */
482   UC_JOINING_GROUP_TAH,                   /* Tah */
483   UC_JOINING_GROUP_TAW,                   /* Taw */
484   UC_JOINING_GROUP_TEH_MARBUTA,           /* Teh_Marbuta */
485   UC_JOINING_GROUP_TEH_MARBUTA_GOAL,      /* Teh_Marbuta_Goal */
486   UC_JOINING_GROUP_TETH,                  /* Teth */
487   UC_JOINING_GROUP_WAW,                   /* Waw */
488   UC_JOINING_GROUP_YEH,                   /* Yeh */
489   UC_JOINING_GROUP_YEH_BARREE,            /* Yeh_Barree */
490   UC_JOINING_GROUP_YEH_WITH_TAIL,         /* Yeh_With_Tail */
491   UC_JOINING_GROUP_YUDH,                  /* Yudh */
492   UC_JOINING_GROUP_YUDH_HE,               /* Yudh_He */
493   UC_JOINING_GROUP_ZAIN,                  /* Zain */
494   UC_JOINING_GROUP_ZHAIN                  /* Zhain */
495 };
496
497 /* Return the name of a joining group.  */
498 extern const char *
499        uc_joining_group_name (int joining_group);
500
501 /* Return the joining group given by name, e.g. "Teh_Marbuta".  */
502 extern int
503        uc_joining_group_byname (const char *joining_group_name);
504
505 /* Return the joining group of a Unicode character.  */
506 extern int
507        uc_joining_group (ucs4_t uc);
508
509 /* ========================================================================= */
510
511 /* Common API for properties.  */
512
513 /* Data type denoting a property.  This is not just a number, but rather a
514    pointer to the test functions, so that programs that use only few of the
515    properties don't have a link-time dependency towards all the tables.  */
516 typedef struct
517 {
518   bool (*test_fn) (ucs4_t uc);
519 }
520 uc_property_t;
521
522 /* Predefined properties.  */
523 /* General.  */
524 extern const uc_property_t UC_PROPERTY_WHITE_SPACE;
525 extern const uc_property_t UC_PROPERTY_ALPHABETIC;
526 extern const uc_property_t UC_PROPERTY_OTHER_ALPHABETIC;
527 extern const uc_property_t UC_PROPERTY_NOT_A_CHARACTER;
528 extern const uc_property_t UC_PROPERTY_DEFAULT_IGNORABLE_CODE_POINT;
529 extern const uc_property_t UC_PROPERTY_OTHER_DEFAULT_IGNORABLE_CODE_POINT;
530 extern const uc_property_t UC_PROPERTY_DEPRECATED;
531 extern const uc_property_t UC_PROPERTY_LOGICAL_ORDER_EXCEPTION;
532 extern const uc_property_t UC_PROPERTY_VARIATION_SELECTOR;
533 extern const uc_property_t UC_PROPERTY_PRIVATE_USE;
534 extern const uc_property_t UC_PROPERTY_UNASSIGNED_CODE_VALUE;
535 /* Case.  */
536 extern const uc_property_t UC_PROPERTY_UPPERCASE;
537 extern const uc_property_t UC_PROPERTY_OTHER_UPPERCASE;
538 extern const uc_property_t UC_PROPERTY_LOWERCASE;
539 extern const uc_property_t UC_PROPERTY_OTHER_LOWERCASE;
540 extern const uc_property_t UC_PROPERTY_TITLECASE;
541 extern const uc_property_t UC_PROPERTY_CASED;
542 extern const uc_property_t UC_PROPERTY_CASE_IGNORABLE;
543 extern const uc_property_t UC_PROPERTY_CHANGES_WHEN_LOWERCASED;
544 extern const uc_property_t UC_PROPERTY_CHANGES_WHEN_UPPERCASED;
545 extern const uc_property_t UC_PROPERTY_CHANGES_WHEN_TITLECASED;
546 extern const uc_property_t UC_PROPERTY_CHANGES_WHEN_CASEFOLDED;
547 extern const uc_property_t UC_PROPERTY_CHANGES_WHEN_CASEMAPPED;
548 extern const uc_property_t UC_PROPERTY_SOFT_DOTTED;
549 /* Identifiers.  */
550 extern const uc_property_t UC_PROPERTY_ID_START;
551 extern const uc_property_t UC_PROPERTY_OTHER_ID_START;
552 extern const uc_property_t UC_PROPERTY_ID_CONTINUE;
553 extern const uc_property_t UC_PROPERTY_OTHER_ID_CONTINUE;
554 extern const uc_property_t UC_PROPERTY_XID_START;
555 extern const uc_property_t UC_PROPERTY_XID_CONTINUE;
556 extern const uc_property_t UC_PROPERTY_PATTERN_WHITE_SPACE;
557 extern const uc_property_t UC_PROPERTY_PATTERN_SYNTAX;
558 /* Shaping and rendering.  */
559 extern const uc_property_t UC_PROPERTY_JOIN_CONTROL;
560 extern const uc_property_t UC_PROPERTY_GRAPHEME_BASE;
561 extern const uc_property_t UC_PROPERTY_GRAPHEME_EXTEND;
562 extern const uc_property_t UC_PROPERTY_OTHER_GRAPHEME_EXTEND;
563 extern const uc_property_t UC_PROPERTY_GRAPHEME_LINK;
564 /* Bidi.  */
565 extern const uc_property_t UC_PROPERTY_BIDI_CONTROL;
566 extern const uc_property_t UC_PROPERTY_BIDI_LEFT_TO_RIGHT;
567 extern const uc_property_t UC_PROPERTY_BIDI_HEBREW_RIGHT_TO_LEFT;
568 extern const uc_property_t UC_PROPERTY_BIDI_ARABIC_RIGHT_TO_LEFT;
569 extern const uc_property_t UC_PROPERTY_BIDI_EUROPEAN_DIGIT;
570 extern const uc_property_t UC_PROPERTY_BIDI_EUR_NUM_SEPARATOR;
571 extern const uc_property_t UC_PROPERTY_BIDI_EUR_NUM_TERMINATOR;
572 extern const uc_property_t UC_PROPERTY_BIDI_ARABIC_DIGIT;
573 extern const uc_property_t UC_PROPERTY_BIDI_COMMON_SEPARATOR;
574 extern const uc_property_t UC_PROPERTY_BIDI_BLOCK_SEPARATOR;
575 extern const uc_property_t UC_PROPERTY_BIDI_SEGMENT_SEPARATOR;
576 extern const uc_property_t UC_PROPERTY_BIDI_WHITESPACE;
577 extern const uc_property_t UC_PROPERTY_BIDI_NON_SPACING_MARK;
578 extern const uc_property_t UC_PROPERTY_BIDI_BOUNDARY_NEUTRAL;
579 extern const uc_property_t UC_PROPERTY_BIDI_PDF;
580 extern const uc_property_t UC_PROPERTY_BIDI_EMBEDDING_OR_OVERRIDE;
581 extern const uc_property_t UC_PROPERTY_BIDI_OTHER_NEUTRAL;
582 /* Numeric.  */
583 extern const uc_property_t UC_PROPERTY_HEX_DIGIT;
584 extern const uc_property_t UC_PROPERTY_ASCII_HEX_DIGIT;
585 /* CJK.  */
586 extern const uc_property_t UC_PROPERTY_IDEOGRAPHIC;
587 extern const uc_property_t UC_PROPERTY_UNIFIED_IDEOGRAPH;
588 extern const uc_property_t UC_PROPERTY_RADICAL;
589 extern const uc_property_t UC_PROPERTY_IDS_BINARY_OPERATOR;
590 extern const uc_property_t UC_PROPERTY_IDS_TRINARY_OPERATOR;
591 /* Misc.  */
592 extern const uc_property_t UC_PROPERTY_ZERO_WIDTH;
593 extern const uc_property_t UC_PROPERTY_SPACE;
594 extern const uc_property_t UC_PROPERTY_NON_BREAK;
595 extern const uc_property_t UC_PROPERTY_ISO_CONTROL;
596 extern const uc_property_t UC_PROPERTY_FORMAT_CONTROL;
597 extern const uc_property_t UC_PROPERTY_DASH;
598 extern const uc_property_t UC_PROPERTY_HYPHEN;
599 extern const uc_property_t UC_PROPERTY_PUNCTUATION;
600 extern const uc_property_t UC_PROPERTY_LINE_SEPARATOR;
601 extern const uc_property_t UC_PROPERTY_PARAGRAPH_SEPARATOR;
602 extern const uc_property_t UC_PROPERTY_QUOTATION_MARK;
603 extern const uc_property_t UC_PROPERTY_SENTENCE_TERMINAL;
604 extern const uc_property_t UC_PROPERTY_TERMINAL_PUNCTUATION;
605 extern const uc_property_t UC_PROPERTY_CURRENCY_SYMBOL;
606 extern const uc_property_t UC_PROPERTY_MATH;
607 extern const uc_property_t UC_PROPERTY_OTHER_MATH;
608 extern const uc_property_t UC_PROPERTY_PAIRED_PUNCTUATION;
609 extern const uc_property_t UC_PROPERTY_LEFT_OF_PAIR;
610 extern const uc_property_t UC_PROPERTY_COMBINING;
611 extern const uc_property_t UC_PROPERTY_COMPOSITE;
612 extern const uc_property_t UC_PROPERTY_DECIMAL_DIGIT;
613 extern const uc_property_t UC_PROPERTY_NUMERIC;
614 extern const uc_property_t UC_PROPERTY_DIACRITIC;
615 extern const uc_property_t UC_PROPERTY_EXTENDER;
616 extern const uc_property_t UC_PROPERTY_IGNORABLE_CONTROL;
617
618 /* Return the property given by name, e.g. "White space".  */
619 extern uc_property_t
620        uc_property_byname (const char *property_name);
621
622 /* Test whether a property is valid.  */
623 #define uc_property_is_valid(property) ((property).test_fn != NULL)
624
625 /* Test whether a Unicode character has a given property.  */
626 extern bool
627        uc_is_property (ucs4_t uc, uc_property_t property);
628 extern bool uc_is_property_white_space (ucs4_t uc);
629 extern bool uc_is_property_alphabetic (ucs4_t uc);
630 extern bool uc_is_property_other_alphabetic (ucs4_t uc);
631 extern bool uc_is_property_not_a_character (ucs4_t uc);
632 extern bool uc_is_property_default_ignorable_code_point (ucs4_t uc);
633 extern bool uc_is_property_other_default_ignorable_code_point (ucs4_t uc);
634 extern bool uc_is_property_deprecated (ucs4_t uc);
635 extern bool uc_is_property_logical_order_exception (ucs4_t uc);
636 extern bool uc_is_property_variation_selector (ucs4_t uc);
637 extern bool uc_is_property_private_use (ucs4_t uc);
638 extern bool uc_is_property_unassigned_code_value (ucs4_t uc);
639 extern bool uc_is_property_uppercase (ucs4_t uc);
640 extern bool uc_is_property_other_uppercase (ucs4_t uc);
641 extern bool uc_is_property_lowercase (ucs4_t uc);
642 extern bool uc_is_property_other_lowercase (ucs4_t uc);
643 extern bool uc_is_property_titlecase (ucs4_t uc);
644 extern bool uc_is_property_cased (ucs4_t uc);
645 extern bool uc_is_property_case_ignorable (ucs4_t uc);
646 extern bool uc_is_property_changes_when_lowercased (ucs4_t uc);
647 extern bool uc_is_property_changes_when_uppercased (ucs4_t uc);
648 extern bool uc_is_property_changes_when_titlecased (ucs4_t uc);
649 extern bool uc_is_property_changes_when_casefolded (ucs4_t uc);
650 extern bool uc_is_property_changes_when_casemapped (ucs4_t uc);
651 extern bool uc_is_property_soft_dotted (ucs4_t uc);
652 extern bool uc_is_property_id_start (ucs4_t uc);
653 extern bool uc_is_property_other_id_start (ucs4_t uc);
654 extern bool uc_is_property_id_continue (ucs4_t uc);
655 extern bool uc_is_property_other_id_continue (ucs4_t uc);
656 extern bool uc_is_property_xid_start (ucs4_t uc);
657 extern bool uc_is_property_xid_continue (ucs4_t uc);
658 extern bool uc_is_property_pattern_white_space (ucs4_t uc);
659 extern bool uc_is_property_pattern_syntax (ucs4_t uc);
660 extern bool uc_is_property_join_control (ucs4_t uc);
661 extern bool uc_is_property_grapheme_base (ucs4_t uc);
662 extern bool uc_is_property_grapheme_extend (ucs4_t uc);
663 extern bool uc_is_property_other_grapheme_extend (ucs4_t uc);
664 extern bool uc_is_property_grapheme_link (ucs4_t uc);
665 extern bool uc_is_property_bidi_control (ucs4_t uc);
666 extern bool uc_is_property_bidi_left_to_right (ucs4_t uc);
667 extern bool uc_is_property_bidi_hebrew_right_to_left (ucs4_t uc);
668 extern bool uc_is_property_bidi_arabic_right_to_left (ucs4_t uc);
669 extern bool uc_is_property_bidi_european_digit (ucs4_t uc);
670 extern bool uc_is_property_bidi_eur_num_separator (ucs4_t uc);
671 extern bool uc_is_property_bidi_eur_num_terminator (ucs4_t uc);
672 extern bool uc_is_property_bidi_arabic_digit (ucs4_t uc);
673 extern bool uc_is_property_bidi_common_separator (ucs4_t uc);
674 extern bool uc_is_property_bidi_block_separator (ucs4_t uc);
675 extern bool uc_is_property_bidi_segment_separator (ucs4_t uc);
676 extern bool uc_is_property_bidi_whitespace (ucs4_t uc);
677 extern bool uc_is_property_bidi_non_spacing_mark (ucs4_t uc);
678 extern bool uc_is_property_bidi_boundary_neutral (ucs4_t uc);
679 extern bool uc_is_property_bidi_pdf (ucs4_t uc);
680 extern bool uc_is_property_bidi_embedding_or_override (ucs4_t uc);
681 extern bool uc_is_property_bidi_other_neutral (ucs4_t uc);
682 extern bool uc_is_property_hex_digit (ucs4_t uc);
683 extern bool uc_is_property_ascii_hex_digit (ucs4_t uc);
684 extern bool uc_is_property_ideographic (ucs4_t uc);
685 extern bool uc_is_property_unified_ideograph (ucs4_t uc);
686 extern bool uc_is_property_radical (ucs4_t uc);
687 extern bool uc_is_property_ids_binary_operator (ucs4_t uc);
688 extern bool uc_is_property_ids_trinary_operator (ucs4_t uc);
689 extern bool uc_is_property_zero_width (ucs4_t uc);
690 extern bool uc_is_property_space (ucs4_t uc);
691 extern bool uc_is_property_non_break (ucs4_t uc);
692 extern bool uc_is_property_iso_control (ucs4_t uc);
693 extern bool uc_is_property_format_control (ucs4_t uc);
694 extern bool uc_is_property_dash (ucs4_t uc);
695 extern bool uc_is_property_hyphen (ucs4_t uc);
696 extern bool uc_is_property_punctuation (ucs4_t uc);
697 extern bool uc_is_property_line_separator (ucs4_t uc);
698 extern bool uc_is_property_paragraph_separator (ucs4_t uc);
699 extern bool uc_is_property_quotation_mark (ucs4_t uc);
700 extern bool uc_is_property_sentence_terminal (ucs4_t uc);
701 extern bool uc_is_property_terminal_punctuation (ucs4_t uc);
702 extern bool uc_is_property_currency_symbol (ucs4_t uc);
703 extern bool uc_is_property_math (ucs4_t uc);
704 extern bool uc_is_property_other_math (ucs4_t uc);
705 extern bool uc_is_property_paired_punctuation (ucs4_t uc);
706 extern bool uc_is_property_left_of_pair (ucs4_t uc);
707 extern bool uc_is_property_combining (ucs4_t uc);
708 extern bool uc_is_property_composite (ucs4_t uc);
709 extern bool uc_is_property_decimal_digit (ucs4_t uc);
710 extern bool uc_is_property_numeric (ucs4_t uc);
711 extern bool uc_is_property_diacritic (ucs4_t uc);
712 extern bool uc_is_property_extender (ucs4_t uc);
713 extern bool uc_is_property_ignorable_control (ucs4_t uc);
714
715 /* ========================================================================= */
716
717 /* Subdivision of the Unicode characters into scripts.  */
718
719 typedef struct
720 {
721   unsigned int code : 21;
722   unsigned int start : 1;
723   unsigned int end : 1;
724 }
725 uc_interval_t;
726 typedef struct
727 {
728   unsigned int nintervals;
729   const uc_interval_t *intervals;
730   const char *name;
731 }
732 uc_script_t;
733
734 /* Return the script of a Unicode character.  */
735 extern const uc_script_t *
736        uc_script (ucs4_t uc);
737
738 /* Return the script given by name, e.g. "HAN".  */
739 extern const uc_script_t *
740        uc_script_byname (const char *script_name);
741
742 /* Test whether a Unicode character belongs to a given script.  */
743 extern bool
744        uc_is_script (ucs4_t uc, const uc_script_t *script);
745
746 /* Get the list of all scripts.  */
747 extern void
748        uc_all_scripts (const uc_script_t **scripts, size_t *count);
749
750 /* ========================================================================= */
751
752 /* Subdivision of the Unicode character range into blocks.  */
753
754 typedef struct
755 {
756   ucs4_t start;
757   ucs4_t end;
758   const char *name;
759 }
760 uc_block_t;
761
762 /* Return the block a character belongs to.  */
763 extern const uc_block_t *
764        uc_block (ucs4_t uc);
765
766 /* Test whether a Unicode character belongs to a given block.  */
767 extern bool
768        uc_is_block (ucs4_t uc, const uc_block_t *block);
769
770 /* Get the list of all blocks.  */
771 extern void
772        uc_all_blocks (const uc_block_t **blocks, size_t *count);
773
774 /* ========================================================================= */
775
776 /* Properties taken from language standards.  */
777
778 /* Test whether a Unicode character is considered whitespace in ISO C 99.  */
779 extern bool
780        uc_is_c_whitespace (ucs4_t uc);
781
782 /* Test whether a Unicode character is considered whitespace in Java.  */
783 extern bool
784        uc_is_java_whitespace (ucs4_t uc);
785
786 enum
787 {
788   UC_IDENTIFIER_START,    /* valid as first or subsequent character */
789   UC_IDENTIFIER_VALID,    /* valid as subsequent character only */
790   UC_IDENTIFIER_INVALID,  /* not valid */
791   UC_IDENTIFIER_IGNORABLE /* ignorable (Java only) */
792 };
793
794 /* Return the categorization of a Unicode character w.r.t. the ISO C 99
795    identifier syntax.  */
796 extern int
797        uc_c_ident_category (ucs4_t uc);
798
799 /* Return the categorization of a Unicode character w.r.t. the Java
800    identifier syntax.  */
801 extern int
802        uc_java_ident_category (ucs4_t uc);
803
804 /* ========================================================================= */
805
806 /* Like ISO C <ctype.h> and <wctype.h>.  These functions are deprecated,
807    because this set of functions was designed with ASCII in mind and cannot
808    reflect the more diverse reality of the Unicode character set.  But they
809    can be a quick-and-dirty porting aid when migrating from wchar_t APIs
810    to Unicode strings.  */
811
812 /* Test for any character for which 'uc_is_alpha' or 'uc_is_digit' is true.  */
813 extern bool
814        uc_is_alnum (ucs4_t uc);
815
816 /* Test for any character for which 'uc_is_upper' or 'uc_is_lower' is true,
817    or any character that is one of a locale-specific set of characters for
818    which none of 'uc_is_cntrl', 'uc_is_digit', 'uc_is_punct', or 'uc_is_space'
819    is true.  */
820 extern bool
821        uc_is_alpha (ucs4_t uc);
822
823 /* Test for any control character.  */
824 extern bool
825        uc_is_cntrl (ucs4_t uc);
826
827 /* Test for any character that corresponds to a decimal-digit character.  */
828 extern bool
829        uc_is_digit (ucs4_t uc);
830
831 /* Test for any character for which 'uc_is_print' is true and 'uc_is_space'
832    is false.  */
833 extern bool
834        uc_is_graph (ucs4_t uc);
835
836 /* Test for any character that corresponds to a lowercase letter or is one
837    of a locale-specific set of characters for which none of 'uc_is_cntrl',
838    'uc_is_digit', 'uc_is_punct', or 'uc_is_space' is true.  */
839 extern bool
840        uc_is_lower (ucs4_t uc);
841
842 /* Test for any printing character.  */
843 extern bool
844        uc_is_print (ucs4_t uc);
845
846 /* Test for any printing character that is one of a locale-specific set of
847    characters for which neither 'uc_is_space' nor 'uc_is_alnum' is true.  */
848 extern bool
849        uc_is_punct (ucs4_t uc);
850
851 /* Test for any character that corresponds to a locale-specific set of
852    characters for which none of 'uc_is_alnum', 'uc_is_graph', or 'uc_is_punct'
853    is true.  */
854 extern bool
855        uc_is_space (ucs4_t uc);
856
857 /* Test for any character that corresponds to an uppercase letter or is one
858    of a locale-specific set of character for which none of 'uc_is_cntrl',
859    'uc_is_digit', 'uc_is_punct', or 'uc_is_space' is true.  */
860 extern bool
861        uc_is_upper (ucs4_t uc);
862
863 /* Test for any character that corresponds to a hexadecimal-digit
864    character.  */
865 extern bool
866        uc_is_xdigit (ucs4_t uc);
867
868 /* GNU extension. */
869 /* Test for any character that corresponds to a standard blank character or
870    a locale-specific set of characters for which 'uc_is_alnum' is false.  */
871 extern bool
872        uc_is_blank (ucs4_t uc);
873
874 /* ========================================================================= */
875
876 #ifdef __cplusplus
877 }
878 #endif
879
880 #endif /* _UNICTYPE_H */