1Unicode::UCD(3pm)      Perl Programmers Reference Guide      Unicode::UCD(3pm)
2
3
4

NAME

6       Unicode::UCD - Unicode character database
7

SYNOPSIS

9           use Unicode::UCD 'charinfo';
10           my $charinfo   = charinfo($codepoint);
11
12           use Unicode::UCD 'charprop';
13           my $value  = charprop($codepoint, $property);
14
15           use Unicode::UCD 'charprops_all';
16           my $all_values_hash_ref = charprops_all($codepoint);
17
18           use Unicode::UCD 'casefold';
19           my $casefold = casefold($codepoint);
20
21           use Unicode::UCD 'all_casefolds';
22           my $all_casefolds_ref = all_casefolds();
23
24           use Unicode::UCD 'casespec';
25           my $casespec = casespec($codepoint);
26
27           use Unicode::UCD 'charblock';
28           my $charblock  = charblock($codepoint);
29
30           use Unicode::UCD 'charscript';
31           my $charscript = charscript($codepoint);
32
33           use Unicode::UCD 'charblocks';
34           my $charblocks = charblocks();
35
36           use Unicode::UCD 'charscripts';
37           my $charscripts = charscripts();
38
39           use Unicode::UCD qw(charscript charinrange);
40           my $range = charscript($script);
41           print "looks like $script\n" if charinrange($range, $codepoint);
42
43           use Unicode::UCD qw(general_categories bidi_types);
44           my $categories = general_categories();
45           my $types = bidi_types();
46
47           use Unicode::UCD 'prop_aliases';
48           my @space_names = prop_aliases("space");
49
50           use Unicode::UCD 'prop_value_aliases';
51           my @gc_punct_names = prop_value_aliases("Gc", "Punct");
52
53           use Unicode::UCD 'prop_values';
54           my @all_EA_short_names = prop_values("East_Asian_Width");
55
56           use Unicode::UCD 'prop_invlist';
57           my @puncts = prop_invlist("gc=punctuation");
58
59           use Unicode::UCD 'prop_invmap';
60           my ($list_ref, $map_ref, $format, $missing)
61                                             = prop_invmap("General Category");
62
63           use Unicode::UCD 'search_invlist';
64           my $index = search_invlist(\@invlist, $code_point);
65
66           # The following function should be used only internally in
67           # implementations of the Unicode Normalization Algorithm, and there
68           # are better choices than it.
69           use Unicode::UCD 'compexcl';
70           my $compexcl = compexcl($codepoint);
71
72           use Unicode::UCD 'namedseq';
73           my $namedseq = namedseq($named_sequence_name);
74
75           my $unicode_version = Unicode::UCD::UnicodeVersion();
76
77           my $convert_to_numeric =
78                     Unicode::UCD::num("\N{RUMI DIGIT ONE}\N{RUMI DIGIT TWO}");
79

DESCRIPTION

81       The Unicode::UCD module offers a series of functions that provide a
82       simple interface to the Unicode Character Database.
83
84   code point argument
85       Some of the functions are called with a code point argument, which is
86       either a decimal or a hexadecimal scalar designating a code point in
87       the platform's native character set (extended to Unicode), or a string
88       containing "U+" followed by hexadecimals designating a Unicode code
89       point.  A leading 0 will force a hexadecimal interpretation, as will a
90       hexadecimal digit that isn't a decimal digit.
91
92       Examples:
93
94           223     # Decimal 223 in native character set
95           0223    # Hexadecimal 223, native (= 547 decimal)
96           0xDF    # Hexadecimal DF, native (= 223 decimal)
97           '0xDF'  # String form of hexadecimal (= 223 decimal)
98           'U+DF'  # Hexadecimal DF, in Unicode's character set
99                                     (= LATIN SMALL LETTER SHARP S)
100
101       Note that the largest code point in Unicode is U+10FFFF.
102
103   charinfo()
104           use Unicode::UCD 'charinfo';
105
106           my $charinfo = charinfo(0x41);
107
108       This returns information about the input "code point argument" as a
109       reference to a hash of fields as defined by the Unicode standard.  If
110       the "code point argument" is not assigned in the standard (i.e., has
111       the general category "Cn" meaning "Unassigned") or is a non-character
112       (meaning it is guaranteed to never be assigned in the standard),
113       "undef" is returned.
114
115       Fields that aren't applicable to the particular code point argument
116       exist in the returned hash, and are empty.
117
118       For results that are less "raw" than this function returns, or to get
119       the values for any property, not just the few covered by this function,
120       use the "charprop()" function.
121
122       The keys in the hash with the meanings of their values are:
123
124       code
125           the input native "code point argument" expressed in hexadecimal,
126           with leading zeros added if necessary to make it contain at least
127           four hexdigits
128
129       name
130           name of code, all IN UPPER CASE.  Some control-type code points do
131           not have names.  This field will be empty for "Surrogate" and
132           "Private Use" code points, and for the others without a name, it
133           will contain a description enclosed in angle brackets, like
134           "<control>".
135
136       category
137           The short name of the general category of code.  This will match
138           one of the keys in the hash returned by "general_categories()".
139
140           The "prop_value_aliases()" function can be used to get all the
141           synonyms of the category name.
142
143       combining
144           the combining class number for code used in the Canonical Ordering
145           Algorithm.  For Unicode 5.1, this is described in Section 3.11
146           "Canonical Ordering Behavior" available at
147           <http://www.unicode.org/versions/Unicode5.1.0/>
148
149           The "prop_value_aliases()" function can be used to get all the
150           synonyms of the combining class number.
151
152       bidi
153           bidirectional type of code.  This will match one of the keys in the
154           hash returned by "bidi_types()".
155
156           The "prop_value_aliases()" function can be used to get all the
157           synonyms of the bidi type name.
158
159       decomposition
160           is empty if code has no decomposition; or is one or more codes
161           (separated by spaces) that, taken in order, represent a
162           decomposition for code.  Each has at least four hexdigits.  The
163           codes may be preceded by a word enclosed in angle brackets, then a
164           space, like "<compat> ", giving the type of decomposition
165
166           This decomposition may be an intermediate one whose components are
167           also decomposable.  Use Unicode::Normalize to get the final
168           decomposition in one step.
169
170       decimal
171           if code represents a decimal digit this is its integer numeric
172           value
173
174       digit
175           if code represents some other digit-like number, this is its
176           integer numeric value
177
178       numeric
179           if code represents a whole or rational number, this is its numeric
180           value.  Rational values are expressed as a string like "1/4".
181
182       mirrored
183           "Y" or "N" designating if code is mirrored in bidirectional text
184
185       unicode10
186           name of code in the Unicode 1.0 standard if one existed for this
187           code point and is different from the current name
188
189       comment
190           As of Unicode 6.0, this is always empty.
191
192       upper
193           is, if non-empty, the uppercase mapping for code expressed as at
194           least four hexdigits.  This indicates that the full uppercase
195           mapping is a single character, and is identical to the simple
196           (single-character only) mapping.  When this field is empty, it
197           means that the simple uppercase mapping is code itself; you'll need
198           some other means, (like "charprop()" or "casespec()" to get the
199           full mapping.
200
201       lower
202           is, if non-empty, the lowercase mapping for code expressed as at
203           least four hexdigits.  This indicates that the full lowercase
204           mapping is a single character, and is identical to the simple
205           (single-character only) mapping.  When this field is empty, it
206           means that the simple lowercase mapping is code itself; you'll need
207           some other means, (like "charprop()" or "casespec()" to get the
208           full mapping.
209
210       title
211           is, if non-empty, the titlecase mapping for code expressed as at
212           least four hexdigits.  This indicates that the full titlecase
213           mapping is a single character, and is identical to the simple
214           (single-character only) mapping.  When this field is empty, it
215           means that the simple titlecase mapping is code itself; you'll need
216           some other means, (like "charprop()" or "casespec()" to get the
217           full mapping.
218
219       block
220           the block code belongs to (used in "\p{Blk=...}").  The
221           "prop_value_aliases()" function can be used to get all the synonyms
222           of the block name.
223
224           See "Blocks versus Scripts".
225
226       script
227           the script code belongs to.  The "prop_value_aliases()" function
228           can be used to get all the synonyms of the script name.  Note that
229           this is the older "Script" property value, and not the improved
230           "Script_Extensions" value.
231
232           See "Blocks versus Scripts".
233
234       Note that you cannot do (de)composition and casing based solely on the
235       decomposition, combining, lower, upper, and title fields; you will need
236       also the "casespec()" function and the "Composition_Exclusion"
237       property.  (Or you could just use the lc(), uc(), and ucfirst()
238       functions, and the Unicode::Normalize module.)
239
240   charprop()
241           use Unicode::UCD 'charprop';
242
243           print charprop(0x41, "Gc"), "\n";
244           print charprop(0x61, "General_Category"), "\n";
245
246         prints
247           Lu
248           Ll
249
250       This returns the value of the Unicode property given by the second
251       parameter for the  "code point argument" given by the first.
252
253       The passed-in property may be specified as any of the synonyms returned
254       by "prop_aliases()".
255
256       The return value is always a scalar, either a string or a number.  For
257       properties where there are synonyms for the values, the synonym
258       returned by this function is the longest, most descriptive form, the
259       one returned by "prop_value_aliases()" when called in a scalar context.
260       Of course, you can call "prop_value_aliases()" on the result to get
261       other synonyms.
262
263       The return values are more "cooked" than the "charinfo()" ones.  For
264       example, the "uc" property value is the actual string containing the
265       full uppercase mapping of the input code point.  You have to go to
266       extra trouble with "charinfo" to get this value from its "upper" hash
267       element when the full mapping differs from the simple one.
268
269       Special note should be made of the return values for a few properties:
270
271       Block
272           The value returned is the new-style (see "Old-style versus new-
273           style block names").
274
275       Decomposition_Mapping
276           Like "charinfo()", the result may be an intermediate decomposition
277           whose components are also decomposable.  Use Unicode::Normalize to
278           get the final decomposition in one step.
279
280           Unlike "charinfo()", this does not include the decomposition type.
281           Use the "Decomposition_Type" property to get that.
282
283       Name_Alias
284           If the input code point's name has more than one synonym, they are
285           returned joined into a single comma-separated string.
286
287       Numeric_Value
288           If the result is a fraction, it is converted into a floating point
289           number to the accuracy of your platform.
290
291       Script_Extensions
292           If the result is multiple script names, they are returned joined
293           into a single comma-separated string.
294
295       When called with a property that is a Perl extension that isn't
296       expressible in a compound form, this function currently returns
297       "undef", as the only two possible values are true or false (1 or 0 I
298       suppose).  This behavior may change in the future, so don't write code
299       that relies on it.  "Present_In" is a Perl extension that is
300       expressible in a bipartite or compound form (for example,
301       "\p{Present_In=4.0}"), so "charprop" accepts it.  But "Any" is a Perl
302       extension that isn't expressible that way, so "charprop" returns
303       "undef" for it.  Also "charprop" returns "undef" for all Perl
304       extensions that are internal-only.
305
306   charprops_all()
307           use Unicode::UCD 'charprops_all';
308
309           my $%properties_of_A_hash_ref = charprops_all("U+41");
310
311       This returns a reference to a hash whose keys are all the distinct
312       Unicode (no Perl extension) properties, and whose values are the
313       respective values for those properties for the input "code point
314       argument".
315
316       Each key is the property name in its longest, most descriptive form.
317       The values are what "charprop()" would return.
318
319       This function is expensive in time and memory.
320
321   charblock()
322           use Unicode::UCD 'charblock';
323
324           my $charblock = charblock(0x41);
325           my $charblock = charblock(1234);
326           my $charblock = charblock(0x263a);
327           my $charblock = charblock("U+263a");
328
329           my $range     = charblock('Armenian');
330
331       With a "code point argument" "charblock()" returns the block the code
332       point belongs to, e.g.  "Basic Latin".  The old-style block name is
333       returned (see "Old-style versus new-style block names").  The
334       "prop_value_aliases()" function can be used to get all the synonyms of
335       the block name.
336
337       If the code point is unassigned, this returns the block it would belong
338       to if it were assigned.  (If the Unicode version being used is so early
339       as to not have blocks, all code points are considered to be in
340       "No_Block".)
341
342       See also "Blocks versus Scripts".
343
344       If supplied with an argument that can't be a code point, "charblock()"
345       tries to do the opposite and interpret the argument as an old-style
346       block name.  On an ASCII platform, the return value is a range set with
347       one range: an anonymous array with a single element that consists of
348       another anonymous array whose first element is the first code point in
349       the block, and whose second element is the final code point in the
350       block.  On an EBCDIC platform, the first two Unicode blocks are not
351       contiguous.  Their range sets are lists containing start-of-range, end-
352       of-range code point pairs.  You can test whether a code point is in a
353       range set using the "charinrange()" function.  (To be precise, each
354       range set contains a third array element, after the range boundary
355       ones: the old_style block name.)
356
357       If the argument to "charblock()" is not a known block, "undef" is
358       returned.
359
360   charscript()
361           use Unicode::UCD 'charscript';
362
363           my $charscript = charscript(0x41);
364           my $charscript = charscript(1234);
365           my $charscript = charscript("U+263a");
366
367           my $range      = charscript('Thai');
368
369       With a "code point argument", "charscript()" returns the script the
370       code point belongs to, e.g., "Latin", "Greek", "Han".  If the code
371       point is unassigned or the Unicode version being used is so early that
372       it doesn't have scripts, this function returns "Unknown".  The
373       "prop_value_aliases()" function can be used to get all the synonyms of
374       the script name.
375
376       Note that the Script_Extensions property is an improved version of the
377       Script property, and you should probably be using that instead, with
378       the "charprop()" function.
379
380       If supplied with an argument that can't be a code point, charscript()
381       tries to do the opposite and interpret the argument as a script name.
382       The return value is a range set: an anonymous array of arrays that
383       contain start-of-range, end-of-range code point pairs. You can test
384       whether a code point is in a range set using the "charinrange()"
385       function.  (To be precise, each range set contains a third array
386       element, after the range boundary ones: the script name.)
387
388       If the "charscript()" argument is not a known script, "undef" is
389       returned.
390
391       See also "Blocks versus Scripts".
392
393   charblocks()
394           use Unicode::UCD 'charblocks';
395
396           my $charblocks = charblocks();
397
398       "charblocks()" returns a reference to a hash with the known block names
399       as the keys, and the code point ranges (see "charblock()") as the
400       values.
401
402       The names are in the old-style (see "Old-style versus new-style block
403       names").
404
405       prop_invmap("block") can be used to get this same data in a different
406       type of data structure.
407
408       prop_values("Block") can be used to get all the known new-style block
409       names as a list, without the code point ranges.
410
411       See also "Blocks versus Scripts".
412
413   charscripts()
414           use Unicode::UCD 'charscripts';
415
416           my $charscripts = charscripts();
417
418       "charscripts()" returns a reference to a hash with the known script
419       names as the keys, and the code point ranges (see "charscript()") as
420       the values.
421
422       prop_invmap("script") can be used to get this same data in a different
423       type of data structure.  Since the Script_Extensions property is an
424       improved version of the Script property, you should instead use
425       prop_invmap("scx").
426
427       "prop_values("Script")" can be used to get all the known script names
428       as a list, without the code point ranges.
429
430       See also "Blocks versus Scripts".
431
432   charinrange()
433       In addition to using the "\p{Blk=...}" and "\P{Blk=...}" constructs,
434       you can also test whether a code point is in the range as returned by
435       "charblock()" and "charscript()" or as the values of the hash returned
436       by "charblocks()" and "charscripts()" by using "charinrange()":
437
438           use Unicode::UCD qw(charscript charinrange);
439
440           $range = charscript('Hiragana');
441           print "looks like hiragana\n" if charinrange($range, $codepoint);
442
443   general_categories()
444           use Unicode::UCD 'general_categories';
445
446           my $categories = general_categories();
447
448       This returns a reference to a hash which has short general category
449       names (such as "Lu", "Nd", "Zs", "S") as keys and long names (such as
450       "UppercaseLetter", "DecimalNumber", "SpaceSeparator", "Symbol") as
451       values.  The hash is reversible in case you need to go from the long
452       names to the short names.  The general category is the one returned
453       from "charinfo()" under the "category" key.
454
455       The "prop_values()" and "prop_value_aliases()" functions can be used as
456       an alternative to this function; the first returning a simple list of
457       the short category names; and the second gets all the synonyms of a
458       given category name.
459
460   bidi_types()
461           use Unicode::UCD 'bidi_types';
462
463           my $categories = bidi_types();
464
465       This returns a reference to a hash which has the short bidi
466       (bidirectional) type names (such as "L", "R") as keys and long names
467       (such as "Left-to-Right", "Right-to-Left") as values.  The hash is
468       reversible in case you need to go from the long names to the short
469       names.  The bidi type is the one returned from "charinfo()" under the
470       "bidi" key.  For the exact meaning of the various bidi classes the
471       Unicode TR9 is recommended reading:
472       <http://www.unicode.org/reports/tr9/> (as of Unicode 5.0.0)
473
474       The "prop_values()" and "prop_value_aliases()" functions can be used as
475       an alternative to this function; the first returning a simple list of
476       the short bidi type names; and the second gets all the synonyms of a
477       given bidi type name.
478
479   compexcl()
480       WARNING: Unicode discourages the use of this function or any of the
481       alternative mechanisms listed in this section (the documentation of
482       "compexcl()"), except internally in implementations of the Unicode
483       Normalization Algorithm.  You should be using Unicode::Normalize
484       directly instead of these.  Using these will likely lead to half-baked
485       results.
486
487           use Unicode::UCD 'compexcl';
488
489           my $compexcl = compexcl(0x09dc);
490
491       This routine returns "undef" if the Unicode version being used is so
492       early that it doesn't have this property.
493
494       "compexcl()" is included for backwards compatibility, but as of Perl
495       5.12 and more modern Unicode versions, for most purposes it is probably
496       more convenient to use one of the following instead:
497
498           my $compexcl = chr(0x09dc) =~ /\p{Comp_Ex};
499           my $compexcl = chr(0x09dc) =~ /\p{Full_Composition_Exclusion};
500
501       or even
502
503           my $compexcl = chr(0x09dc) =~ /\p{CE};
504           my $compexcl = chr(0x09dc) =~ /\p{Composition_Exclusion};
505
506       The first two forms return true if the "code point argument" should not
507       be produced by composition normalization.  For the final two forms to
508       return true, it is additionally required that this fact not otherwise
509       be determinable from the Unicode data base.
510
511       This routine behaves identically to the final two forms.  That is, it
512       does not return true if the code point has a decomposition consisting
513       of another single code point, nor if its decomposition starts with a
514       code point whose combining class is non-zero.  Code points that meet
515       either of these conditions should also not be produced by composition
516       normalization, which is probably why you should use the
517       "Full_Composition_Exclusion" property instead, as shown above.
518
519       The routine returns false otherwise.
520
521   casefold()
522           use Unicode::UCD 'casefold';
523
524           my $casefold = casefold(0xDF);
525           if (defined $casefold) {
526               my @full_fold_hex = split / /, $casefold->{'full'};
527               my $full_fold_string =
528                           join "", map {chr(hex($_))} @full_fold_hex;
529               my @turkic_fold_hex =
530                               split / /, ($casefold->{'turkic'} ne "")
531                                               ? $casefold->{'turkic'}
532                                               : $casefold->{'full'};
533               my $turkic_fold_string =
534                               join "", map {chr(hex($_))} @turkic_fold_hex;
535           }
536           if (defined $casefold && $casefold->{'simple'} ne "") {
537               my $simple_fold_hex = $casefold->{'simple'};
538               my $simple_fold_string = chr(hex($simple_fold_hex));
539           }
540
541       This returns the (almost) locale-independent case folding of the
542       character specified by the "code point argument".  (Starting in Perl
543       v5.16, the core function "fc()" returns the "full" mapping (described
544       below) faster than this does, and for entire strings.)
545
546       If there is no case folding for the input code point, "undef" is
547       returned.
548
549       If there is a case folding for that code point, a reference to a hash
550       with the following fields is returned:
551
552       code
553           the input native "code point argument" expressed in hexadecimal,
554           with leading zeros added if necessary to make it contain at least
555           four hexdigits
556
557       full
558           one or more codes (separated by spaces) that, taken in order, give
559           the code points for the case folding for code.  Each has at least
560           four hexdigits.
561
562       simple
563           is empty, or is exactly one code with at least four hexdigits which
564           can be used as an alternative case folding when the calling program
565           cannot cope with the fold being a sequence of multiple code points.
566           If full is just one code point, then simple equals full.  If there
567           is no single code point folding defined for code, then simple is
568           the empty string.  Otherwise, it is an inferior, but still better-
569           than-nothing alternative folding to full.
570
571       mapping
572           is the same as simple if simple is not empty, and it is the same as
573           full otherwise.  It can be considered to be the simplest possible
574           folding for code.  It is defined primarily for backwards
575           compatibility.
576
577       status
578           is "C" (for "common") if the best possible fold is a single code
579           point (simple equals full equals mapping).  It is "S" if there are
580           distinct folds, simple and full (mapping equals simple).  And it is
581           "F" if there is only a full fold (mapping equals full; simple is
582           empty).  Note that this describes the contents of mapping.  It is
583           defined primarily for backwards compatibility.
584
585           For Unicode versions between 3.1 and 3.1.1 inclusive, status can
586           also be "I" which is the same as "C" but is a special case for
587           dotted uppercase I and dotless lowercase i:
588
589           * If you use this "I" mapping
590               the result is case-insensitive, but dotless and dotted I's are
591               not distinguished
592
593           * If you exclude this "I" mapping
594               the result is not fully case-insensitive, but dotless and
595               dotted I's are distinguished
596
597       turkic
598           contains any special folding for Turkic languages.  For versions of
599           Unicode starting with 3.2, this field is empty unless code has a
600           different folding in Turkic languages, in which case it is one or
601           more codes (separated by spaces) that, taken in order, give the
602           code points for the case folding for code in those languages.  Each
603           code has at least four hexdigits.  Note that this folding does not
604           maintain canonical equivalence without additional processing.
605
606           For Unicode versions between 3.1 and 3.1.1 inclusive, this field is
607           empty unless there is a special folding for Turkic languages, in
608           which case status is "I", and mapping, full, simple, and turkic are
609           all equal.
610
611       Programs that want complete generality and the best folding results
612       should use the folding contained in the full field.  But note that the
613       fold for some code points will be a sequence of multiple code points.
614
615       Programs that can't cope with the fold mapping being multiple code
616       points can use the folding contained in the simple field, with the loss
617       of some generality.  In Unicode 5.1, about 7% of the defined foldings
618       have no single code point folding.
619
620       The mapping and status fields are provided for backwards compatibility
621       for existing programs.  They contain the same values as in previous
622       versions of this function.
623
624       Locale is not completely independent.  The turkic field contains
625       results to use when the locale is a Turkic language.
626
627       For more information about case mappings see
628       <http://www.unicode.org/unicode/reports/tr21>
629
630   all_casefolds()
631           use Unicode::UCD 'all_casefolds';
632
633           my $all_folds_ref = all_casefolds();
634           foreach my $char_with_casefold (sort { $a <=> $b }
635                                           keys %$all_folds_ref)
636           {
637               printf "%04X:", $char_with_casefold;
638               my $casefold = $all_folds_ref->{$char_with_casefold};
639
640               # Get folds for $char_with_casefold
641
642               my @full_fold_hex = split / /, $casefold->{'full'};
643               my $full_fold_string =
644                           join "", map {chr(hex($_))} @full_fold_hex;
645               print " full=", join " ", @full_fold_hex;
646               my @turkic_fold_hex =
647                               split / /, ($casefold->{'turkic'} ne "")
648                                               ? $casefold->{'turkic'}
649                                               : $casefold->{'full'};
650               my $turkic_fold_string =
651                               join "", map {chr(hex($_))} @turkic_fold_hex;
652               print "; turkic=", join " ", @turkic_fold_hex;
653               if (defined $casefold && $casefold->{'simple'} ne "") {
654                   my $simple_fold_hex = $casefold->{'simple'};
655                   my $simple_fold_string = chr(hex($simple_fold_hex));
656                   print "; simple=$simple_fold_hex";
657               }
658               print "\n";
659           }
660
661       This returns all the case foldings in the current version of Unicode in
662       the form of a reference to a hash.  Each key to the hash is the decimal
663       representation of a Unicode character that has a casefold to other than
664       itself.  The casefold of a semi-colon is itself, so it isn't in the
665       hash; likewise for a lowercase "a", but there is an entry for a capital
666       "A".  The hash value for each key is another hash, identical to what is
667       returned by "casefold()" if called with that code point as its
668       argument.  So the value "all_casefolds()->{ord("A")}'" is equivalent to
669       "casefold(ord("A"))";
670
671   casespec()
672           use Unicode::UCD 'casespec';
673
674           my $casespec = casespec(0xFB00);
675
676       This returns the potentially locale-dependent case mappings of the
677       "code point argument".  The mappings may be longer than a single code
678       point (which the basic Unicode case mappings as returned by
679       "charinfo()" never are).
680
681       If there are no case mappings for the "code point argument", or if all
682       three possible mappings (lower, title and upper) result in single code
683       points and are locale independent and unconditional, "undef" is
684       returned (which means that the case mappings, if any, for the code
685       point are those returned by "charinfo()").
686
687       Otherwise, a reference to a hash giving the mappings (or a reference to
688       a hash of such hashes, explained below) is returned with the following
689       keys and their meanings:
690
691       The keys in the bottom layer hash with the meanings of their values
692       are:
693
694       code
695           the input native "code point argument" expressed in hexadecimal,
696           with leading zeros added if necessary to make it contain at least
697           four hexdigits
698
699       lower
700           one or more codes (separated by spaces) that, taken in order, give
701           the code points for the lower case of code.  Each has at least four
702           hexdigits.
703
704       title
705           one or more codes (separated by spaces) that, taken in order, give
706           the code points for the title case of code.  Each has at least four
707           hexdigits.
708
709       upper
710           one or more codes (separated by spaces) that, taken in order, give
711           the code points for the upper case of code.  Each has at least four
712           hexdigits.
713
714       condition
715           the conditions for the mappings to be valid.  If "undef", the
716           mappings are always valid.  When defined, this field is a list of
717           conditions, all of which must be true for the mappings to be valid.
718           The list consists of one or more locales (see below) and/or
719           contexts (explained in the next paragraph), separated by spaces.
720           (Other than as used to separate elements, spaces are to be
721           ignored.)  Case distinctions in the condition list are not
722           significant.  Conditions preceded by "NON_" represent the negation
723           of the condition.
724
725           A context is one of those defined in the Unicode standard.  For
726           Unicode 5.1, they are defined in Section 3.13 "Default Case
727           Operations" available at
728           <http://www.unicode.org/versions/Unicode5.1.0/>.  These are for
729           context-sensitive casing.
730
731       The hash described above is returned for locale-independent casing,
732       where at least one of the mappings has length longer than one.  If
733       "undef" is returned, the code point may have mappings, but if so, all
734       are length one, and are returned by "charinfo()".  Note that when this
735       function does return a value, it will be for the complete set of
736       mappings for a code point, even those whose length is one.
737
738       If there are additional casing rules that apply only in certain
739       locales, an additional key for each will be defined in the returned
740       hash.  Each such key will be its locale name, defined as a 2-letter ISO
741       3166 country code, possibly followed by a "_" and a 2-letter ISO
742       language code (possibly followed by a "_" and a variant code).  You can
743       find the lists of all possible locales, see Locale::Country and
744       Locale::Language.  (In Unicode 6.0, the only locales returned by this
745       function are "lt", "tr", and "az".)
746
747       Each locale key is a reference to a hash that has the form above, and
748       gives the casing rules for that particular locale, which take
749       precedence over the locale-independent ones when in that locale.
750
751       If the only casing for a code point is locale-dependent, then the
752       returned hash will not have any of the base keys, like "code", "upper",
753       etc., but will contain only locale keys.
754
755       For more information about case mappings see
756       <http://www.unicode.org/unicode/reports/tr21/>
757
758   namedseq()
759           use Unicode::UCD 'namedseq';
760
761           my $namedseq = namedseq("KATAKANA LETTER AINU P");
762           my @namedseq = namedseq("KATAKANA LETTER AINU P");
763           my %namedseq = namedseq();
764
765       If used with a single argument in a scalar context, returns the string
766       consisting of the code points of the named sequence, or "undef" if no
767       named sequence by that name exists.  If used with a single argument in
768       a list context, it returns the list of the ordinals of the code points.
769
770       If used with no arguments in a list context, it returns a hash with the
771       names of all the named sequences as the keys and their sequences as
772       strings as the values.  Otherwise, it returns "undef" or an empty list
773       depending on the context.
774
775       This function only operates on officially approved (not provisional)
776       named sequences.
777
778       Note that as of Perl 5.14, "\N{KATAKANA LETTER AINU P}" will insert the
779       named sequence into double-quoted strings, and
780       "charnames::string_vianame("KATAKANA LETTER AINU P")" will return the
781       same string this function does, but will also operate on character
782       names that aren't named sequences, without you having to know which are
783       which.  See charnames.
784
785   num()
786           use Unicode::UCD 'num';
787
788           my $val = num("123");
789           my $one_quarter = num("\N{VULGAR FRACTION 1/4}");
790
791       "num()" returns the numeric value of the input Unicode string; or
792       "undef" if it doesn't think the entire string has a completely valid,
793       safe numeric value.
794
795       If the string is just one character in length, the Unicode numeric
796       value is returned if it has one, or "undef" otherwise.  Note that this
797       need not be a whole number.  "num("\N{TIBETAN DIGIT HALF ZERO}")", for
798       example returns -0.5.
799
800       If the string is more than one character, "undef" is returned unless
801       all its characters are decimal digits (that is, they would match
802       "\d+"), from the same script.  For example if you have an ASCII '0' and
803       a Bengali '3', mixed together, they aren't considered a valid number,
804       and "undef" is returned.  A further restriction is that the digits all
805       have to be of the same form.  A half-width digit mixed with a full-
806       width one will return "undef".  The Arabic script has two sets of
807       digits;  "num" will return "undef" unless all the digits in the string
808       come from the same set.
809
810       "num" errs on the side of safety, and there may be valid strings of
811       decimal digits that it doesn't recognize.  Note that Unicode defines a
812       number of "digit" characters that aren't "decimal digit" characters.
813       "Decimal digits" have the property that they have a positional value,
814       i.e., there is a units position, a 10's position, a 100's, etc, AND
815       they are arranged in Unicode in blocks of 10 contiguous code points.
816       The Chinese digits, for example, are not in such a contiguous block,
817       and so Unicode doesn't view them as decimal digits, but merely digits,
818       and so "\d" will not match them.  A single-character string containing
819       one of these digits will have its decimal value returned by "num", but
820       any longer string containing only these digits will return "undef".
821
822       Strings of multiple sub- and superscripts are not recognized as
823       numbers.  You can use either of the compatibility decompositions in
824       Unicode::Normalize to change these into digits, and then call "num" on
825       the result.
826
827   prop_aliases()
828           use Unicode::UCD 'prop_aliases';
829
830           my ($short_name, $full_name, @other_names) = prop_aliases("space");
831           my $same_full_name = prop_aliases("Space");     # Scalar context
832           my ($same_short_name) = prop_aliases("Space");  # gets 0th element
833           print "The full name is $full_name\n";
834           print "The short name is $short_name\n";
835           print "The other aliases are: ", join(", ", @other_names), "\n";
836
837           prints:
838           The full name is White_Space
839           The short name is WSpace
840           The other aliases are: Space
841
842       Most Unicode properties have several synonymous names.  Typically,
843       there is at least a short name, convenient to type, and a long name
844       that more fully describes the property, and hence is more easily
845       understood.
846
847       If you know one name for a Unicode property, you can use "prop_aliases"
848       to find either the long name (when called in scalar context), or a list
849       of all of the names, somewhat ordered so that the short name is in the
850       0th element, the long name in the next element, and any other synonyms
851       are in the remaining elements, in no particular order.
852
853       The long name is returned in a form nicely capitalized, suitable for
854       printing.
855
856       The input parameter name is loosely matched, which means that white
857       space, hyphens, and underscores are ignored (except for the trailing
858       underscore in the old_form grandfathered-in "L_", which is better
859       written as "LC", and both of which mean "General_Category=Cased
860       Letter").
861
862       If the name is unknown, "undef" is returned (or an empty list in list
863       context).  Note that Perl typically recognizes property names in
864       regular expressions with an optional ""Is_"" (with or without the
865       underscore) prefixed to them, such as "\p{isgc=punct}".  This function
866       does not recognize those in the input, returning "undef".  Nor are they
867       included in the output as possible synonyms.
868
869       "prop_aliases" does know about the Perl extensions to Unicode
870       properties, such as "Any" and "XPosixAlpha", and the single form
871       equivalents to Unicode properties such as "XDigit", "Greek",
872       "In_Greek", and "Is_Greek".  The final example demonstrates that the
873       "Is_" prefix is recognized for these extensions; it is needed to
874       resolve ambiguities.  For example, "prop_aliases('lc')" returns the
875       list "(lc, Lowercase_Mapping)", but "prop_aliases('islc')" returns
876       "(Is_LC, Cased_Letter)".  This is because "islc" is a Perl extension
877       which is short for "General_Category=Cased Letter".  The lists returned
878       for the Perl extensions will not include the "Is_" prefix (whether or
879       not the input had it) unless needed to resolve ambiguities, as shown in
880       the "islc" example, where the returned list had one element containing
881       "Is_", and the other without.
882
883       It is also possible for the reverse to happen:  "prop_aliases('isc')"
884       returns the list "(isc, ISO_Comment)"; whereas "prop_aliases('c')"
885       returns "(C, Other)" (the latter being a Perl extension meaning
886       "General_Category=Other".  "Properties accessible through Unicode::UCD"
887       in perluniprops lists the available forms, including which ones are
888       discouraged from use.
889
890       Those discouraged forms are accepted as input to "prop_aliases", but
891       are not returned in the lists.  "prop_aliases('isL&')" and
892       "prop_aliases('isL_')", which are old synonyms for "Is_LC" and should
893       not be used in new code, are examples of this.  These both return
894       "(Is_LC, Cased_Letter)".  Thus this function allows you to take a
895       discouraged form, and find its acceptable alternatives.  The same goes
896       with single-form Block property equivalences.  Only the forms that
897       begin with "In_" are not discouraged; if you pass "prop_aliases" a
898       discouraged form, you will get back the equivalent ones that begin with
899       "In_".  It will otherwise look like a new-style block name (see.  "Old-
900       style versus new-style block names").
901
902       "prop_aliases" does not know about any user-defined properties, and
903       will return "undef" if called with one of those.  Likewise for Perl
904       internal properties, with the exception of "Perl_Decimal_Digit" which
905       it does know about (and which is documented below in "prop_invmap()").
906
907   prop_values()
908           use Unicode::UCD 'prop_values';
909
910           print "AHex values are: ", join(", ", prop_values("AHex")),
911                                      "\n";
912         prints:
913           AHex values are: N, Y
914
915       Some Unicode properties have a restricted set of legal values.  For
916       example, all binary properties are restricted to just "true" or
917       "false"; and there are only a few dozen possible General Categories.
918       Use "prop_values" to find out if a given property is one such, and if
919       so, to get a list of the values:
920
921           print join ", ", prop_values("NFC_Quick_Check");
922         prints:
923           M, N, Y
924
925       If the property doesn't have such a restricted set, "undef" is
926       returned.
927
928       There are usually several synonyms for each possible value.  Use
929       "prop_value_aliases()" to access those.
930
931       Case, white space, hyphens, and underscores are ignored in the input
932       property name (except for the trailing underscore in the old-form
933       grandfathered-in general category property value "L_", which is better
934       written as "LC").
935
936       If the property name is unknown, "undef" is returned.  Note that Perl
937       typically recognizes property names in regular expressions with an
938       optional ""Is_"" (with or without the underscore) prefixed to them,
939       such as "\p{isgc=punct}".  This function does not recognize those in
940       the property parameter, returning "undef".
941
942       For the block property, new-style block names are returned (see "Old-
943       style versus new-style block names").
944
945       "prop_values" does not know about any user-defined properties, and will
946       return "undef" if called with one of those.
947
948   prop_value_aliases()
949           use Unicode::UCD 'prop_value_aliases';
950
951           my ($short_name, $full_name, @other_names)
952                                          = prop_value_aliases("Gc", "Punct");
953           my $same_full_name = prop_value_aliases("Gc", "P");   # Scalar cntxt
954           my ($same_short_name) = prop_value_aliases("Gc", "P"); # gets 0th
955                                                                  # element
956           print "The full name is $full_name\n";
957           print "The short name is $short_name\n";
958           print "The other aliases are: ", join(", ", @other_names), "\n";
959
960         prints:
961           The full name is Punctuation
962           The short name is P
963           The other aliases are: Punct
964
965       Some Unicode properties have a restricted set of legal values.  For
966       example, all binary properties are restricted to just "true" or
967       "false"; and there are only a few dozen possible General Categories.
968
969       You can use "prop_values()" to find out if a given property is one
970       which has a restricted set of values, and if so, what those values are.
971       But usually each value actually has several synonyms.  For example, in
972       Unicode binary properties, truth can be represented by any of the
973       strings "Y", "Yes", "T", or "True"; and the General Category
974       "Punctuation" by that string, or "Punct", or simply "P".
975
976       Like property names, there is typically at least a short name for each
977       such property-value, and a long name.  If you know any name of the
978       property-value (which you can get by "prop_values()", you can use
979       "prop_value_aliases"() to get the long name (when called in scalar
980       context), or a list of all the names, with the short name in the 0th
981       element, the long name in the next element, and any other synonyms in
982       the remaining elements, in no particular order, except that any all-
983       numeric synonyms will be last.
984
985       The long name is returned in a form nicely capitalized, suitable for
986       printing.
987
988       Case, white space, hyphens, and underscores are ignored in the input
989       parameters (except for the trailing underscore in the old-form
990       grandfathered-in general category property value "L_", which is better
991       written as "LC").
992
993       If either name is unknown, "undef" is returned.  Note that Perl
994       typically recognizes property names in regular expressions with an
995       optional ""Is_"" (with or without the underscore) prefixed to them,
996       such as "\p{isgc=punct}".  This function does not recognize those in
997       the property parameter, returning "undef".
998
999       If called with a property that doesn't have synonyms for its values, it
1000       returns the input value, possibly normalized with capitalization and
1001       underscores, but not necessarily checking that the input value is
1002       valid.
1003
1004       For the block property, new-style block names are returned (see "Old-
1005       style versus new-style block names").
1006
1007       To find the synonyms for single-forms, such as "\p{Any}", use
1008       "prop_aliases()" instead.
1009
1010       "prop_value_aliases" does not know about any user-defined properties,
1011       and will return "undef" if called with one of those.
1012
1013   prop_invlist()
1014       "prop_invlist" returns an inversion list (described below) that defines
1015       all the code points for the binary Unicode property (or
1016       "property=value" pair) given by the input parameter string:
1017
1018        use feature 'say';
1019        use Unicode::UCD 'prop_invlist';
1020        say join ", ", prop_invlist("Any");
1021
1022        prints:
1023        0, 1114112
1024
1025       If the input is unknown "undef" is returned in scalar context; an
1026       empty-list in list context.  If the input is known, the number of
1027       elements in the list is returned if called in scalar context.
1028
1029       perluniprops gives the list of properties that this function accepts,
1030       as well as all the possible forms for them (including with the optional
1031       "Is_" prefixes).  (Except this function doesn't accept any Perl-
1032       internal properties, some of which are listed there.) This function
1033       uses the same loose or tighter matching rules for resolving the input
1034       property's name as is done for regular expressions.  These are also
1035       specified in perluniprops.  Examples of using the "property=value" form
1036       are:
1037
1038        say join ", ", prop_invlist("Script_Extensions=Shavian");
1039
1040        prints:
1041        66640, 66688
1042
1043        say join ", ", prop_invlist("ASCII_Hex_Digit=No");
1044
1045        prints:
1046        0, 48, 58, 65, 71, 97, 103
1047
1048        say join ", ", prop_invlist("ASCII_Hex_Digit=Yes");
1049
1050        prints:
1051        48, 58, 65, 71, 97, 103
1052
1053       Inversion lists are a compact way of specifying Unicode property-value
1054       definitions.  The 0th item in the list is the lowest code point that
1055       has the property-value.  The next item (item [1]) is the lowest code
1056       point beyond that one that does NOT have the property-value.  And the
1057       next item beyond that ([2]) is the lowest code point beyond that one
1058       that does have the property-value, and so on.  Put another way, each
1059       element in the list gives the beginning of a range that has the
1060       property-value (for even numbered elements), or doesn't have the
1061       property-value (for odd numbered elements).  The name for this data
1062       structure stems from the fact that each element in the list toggles (or
1063       inverts) whether the corresponding range is or isn't on the list.
1064
1065       In the final example above, the first ASCII Hex digit is code point 48,
1066       the character "0", and all code points from it through 57 (a "9") are
1067       ASCII hex digits.  Code points 58 through 64 aren't, but 65 (an "A")
1068       through 70 (an "F") are, as are 97 ("a") through 102 ("f").  103 starts
1069       a range of code points that aren't ASCII hex digits.  That range
1070       extends to infinity, which on your computer can be found in the
1071       variable $Unicode::UCD::MAX_CP.  (This variable is as close to infinity
1072       as Perl can get on your platform, and may be too high for some
1073       operations to work; you may wish to use a smaller number for your
1074       purposes.)
1075
1076       Note that the inversion lists returned by this function can possibly
1077       include non-Unicode code points, that is anything above 0x10FFFF.
1078       Unicode properties are not defined on such code points.  You might wish
1079       to change the output to not include these.  Simply add 0x110000 at the
1080       end of the non-empty returned list if it isn't already that value; and
1081       pop that value if it is; like:
1082
1083        my @list = prop_invlist("foo");
1084        if (@list) {
1085            if ($list[-1] == 0x110000) {
1086                pop @list;  # Defeat the turning on for above Unicode
1087            }
1088            else {
1089                push @list, 0x110000; # Turn off for above Unicode
1090            }
1091        }
1092
1093       It is a simple matter to expand out an inversion list to a full list of
1094       all code points that have the property-value:
1095
1096        my @invlist = prop_invlist($property_name);
1097        die "empty" unless @invlist;
1098        my @full_list;
1099        for (my $i = 0; $i < @invlist; $i += 2) {
1100           my $upper = ($i + 1) < @invlist
1101                       ? $invlist[$i+1] - 1      # In range
1102                       : $Unicode::UCD::MAX_CP;  # To infinity.
1103           for my $j ($invlist[$i] .. $upper) {
1104               push @full_list, $j;
1105           }
1106        }
1107
1108       "prop_invlist" does not know about any user-defined nor Perl internal-
1109       only properties, and will return "undef" if called with one of those.
1110
1111       The "search_invlist()" function is provided for finding a code point
1112       within an inversion list.
1113
1114   prop_invmap()
1115        use Unicode::UCD 'prop_invmap';
1116        my ($list_ref, $map_ref, $format, $default)
1117                                             = prop_invmap("General Category");
1118
1119       "prop_invmap" is used to get the complete mapping definition for a
1120       property, in the form of an inversion map.  An inversion map consists
1121       of two parallel arrays.  One is an ordered list of code points that
1122       mark range beginnings, and the other gives the value (or mapping) that
1123       all code points in the corresponding range have.
1124
1125       "prop_invmap" is called with the name of the desired property.  The
1126       name is loosely matched, meaning that differences in case, white-space,
1127       hyphens, and underscores are not meaningful (except for the trailing
1128       underscore in the old-form grandfathered-in property "L_", which is
1129       better written as "LC", or even better, "Gc=LC").
1130
1131       Many Unicode properties have more than one name (or alias).
1132       "prop_invmap" understands all of these, including Perl extensions to
1133       them.  Ambiguities are resolved as described above for "prop_aliases()"
1134       (except if a property has both a complete mapping, and a binary "Y"/"N"
1135       mapping, then specifying the property name prefixed by "is" causes the
1136       binary one to be returned).  The Perl internal property
1137       "Perl_Decimal_Digit, described below, is also accepted.  An empty list
1138       is returned if the property name is unknown.  See "Properties
1139       accessible through Unicode::UCD" in perluniprops for the properties
1140       acceptable as inputs to this function.
1141
1142       It is a fatal error to call this function except in list context.
1143
1144       In addition to the two arrays that form the inversion map,
1145       "prop_invmap" returns two other values; one is a scalar that gives some
1146       details as to the format of the entries of the map array; the other is
1147       a default value, useful in maps whose format name begins with the
1148       letter "a", as described below in its subsection; and for specialized
1149       purposes, such as converting to another data structure, described at
1150       the end of this main section.
1151
1152       This means that "prop_invmap" returns a 4 element list.  For example,
1153
1154        my ($blocks_ranges_ref, $blocks_maps_ref, $format, $default)
1155                                                        = prop_invmap("Block");
1156
1157       In this call, the two arrays will be populated as shown below (for
1158       Unicode 6.0):
1159
1160        Index  @blocks_ranges  @blocks_maps
1161          0        0x0000      Basic Latin
1162          1        0x0080      Latin-1 Supplement
1163          2        0x0100      Latin Extended-A
1164          3        0x0180      Latin Extended-B
1165          4        0x0250      IPA Extensions
1166          5        0x02B0      Spacing Modifier Letters
1167          6        0x0300      Combining Diacritical Marks
1168          7        0x0370      Greek and Coptic
1169          8        0x0400      Cyrillic
1170         ...
1171        233        0x2B820     No_Block
1172        234        0x2F800     CJK Compatibility Ideographs Supplement
1173        235        0x2FA20     No_Block
1174        236        0xE0000     Tags
1175        237        0xE0080     No_Block
1176        238        0xE0100     Variation Selectors Supplement
1177        239        0xE01F0     No_Block
1178        240        0xF0000     Supplementary Private Use Area-A
1179        241        0x100000    Supplementary Private Use Area-B
1180        242        0x110000    No_Block
1181
1182       The first line (with Index [0]) means that the value for code point 0
1183       is "Basic Latin".  The entry "0x0080" in the @blocks_ranges column in
1184       the second line means that the value from the first line, "Basic
1185       Latin", extends to all code points in the range from 0 up to but not
1186       including 0x0080, that is, through 127.  In other words, the code
1187       points from 0 to 127 are all in the "Basic Latin" block.  Similarly,
1188       all code points in the range from 0x0080 up to (but not including)
1189       0x0100 are in the block named "Latin-1 Supplement", etc.  (Notice that
1190       the return is the old-style block names; see "Old-style versus new-
1191       style block names").
1192
1193       The final line (with Index [242]) means that the value for all code
1194       points above the legal Unicode maximum code point have the value
1195       "No_Block", which is the term Unicode uses for a non-existing block.
1196
1197       The arrays completely specify the mappings for all possible code
1198       points.  The final element in an inversion map returned by this
1199       function will always be for the range that consists of all the code
1200       points that aren't legal Unicode, but that are expressible on the
1201       platform.  (That is, it starts with code point 0x110000, the first code
1202       point above the legal Unicode maximum, and extends to infinity.) The
1203       value for that range will be the same that any typical unassigned code
1204       point has for the specified property.  (Certain unassigned code points
1205       are not "typical"; for example the non-character code points, or those
1206       in blocks that are to be written right-to-left.  The above-Unicode
1207       range's value is not based on these atypical code points.)  It could be
1208       argued that, instead of treating these as unassigned Unicode code
1209       points, the value for this range should be "undef".  If you wish, you
1210       can change the returned arrays accordingly.
1211
1212       The maps for almost all properties are simple scalars that should be
1213       interpreted as-is.  These values are those given in the Unicode-
1214       supplied data files, which may be inconsistent as to capitalization and
1215       as to which synonym for a property-value is given.  The results may be
1216       normalized by using the "prop_value_aliases()" function.
1217
1218       There are exceptions to the simple scalar maps.  Some properties have
1219       some elements in their map list that are themselves lists of scalars;
1220       and some special strings are returned that are not to be interpreted
1221       as-is.  Element [2] (placed into $format in the example above) of the
1222       returned four element list tells you if the map has any of these
1223       special elements or not, as follows:
1224
1225       "s" means all the elements of the map array are simple scalars, with no
1226           special elements.  Almost all properties are like this, like the
1227           "block" example above.
1228
1229       "sl"
1230           means that some of the map array elements have the form given by
1231           "s", and the rest are lists of scalars.  For example, here is a
1232           portion of the output of calling "prop_invmap"() with the "Script
1233           Extensions" property:
1234
1235            @scripts_ranges  @scripts_maps
1236                 ...
1237                 0x0953      Devanagari
1238                 0x0964      [ Bengali, Devanagari, Gurumukhi, Oriya ]
1239                 0x0966      Devanagari
1240                 0x0970      Common
1241
1242           Here, the code points 0x964 and 0x965 are both used in Bengali,
1243           Devanagari, Gurmukhi, and Oriya, but no other scripts.
1244
1245           The Name_Alias property is also of this form.  But each scalar
1246           consists of two components:  1) the name, and 2) the type of alias
1247           this is.  They are separated by a colon and a space.  In Unicode
1248           6.1, there are several alias types:
1249
1250           "correction"
1251               indicates that the name is a corrected form for the original
1252               name (which remains valid) for the same code point.
1253
1254           "control"
1255               adds a new name for a control character.
1256
1257           "alternate"
1258               is an alternate name for a character
1259
1260           "figment"
1261               is a name for a character that has been documented but was
1262               never in any actual standard.
1263
1264           "abbreviation"
1265               is a common abbreviation for a character
1266
1267           The lists are ordered (roughly) so the most preferred names come
1268           before less preferred ones.
1269
1270           For example,
1271
1272            @aliases_ranges        @alias_maps
1273               ...
1274               0x009E        [ 'PRIVACY MESSAGE: control', 'PM: abbreviation' ]
1275               0x009F        [ 'APPLICATION PROGRAM COMMAND: control',
1276                               'APC: abbreviation'
1277                             ]
1278               0x00A0        'NBSP: abbreviation'
1279               0x00A1        ""
1280               0x00AD        'SHY: abbreviation'
1281               0x00AE        ""
1282               0x01A2        'LATIN CAPITAL LETTER GHA: correction'
1283               0x01A3        'LATIN SMALL LETTER GHA: correction'
1284               0x01A4        ""
1285               ...
1286
1287           A map to the empty string means that there is no alias defined for
1288           the code point.
1289
1290       "a" is like "s" in that all the map array elements are scalars, but
1291           here they are restricted to all being integers, and some have to be
1292           adjusted (hence the name "a") to get the correct result.  For
1293           example, in:
1294
1295            my ($uppers_ranges_ref, $uppers_maps_ref, $format, $default)
1296                                     = prop_invmap("Simple_Uppercase_Mapping");
1297
1298           the returned arrays look like this:
1299
1300            @$uppers_ranges_ref    @$uppers_maps_ref   Note
1301                  0                      0
1302                 97                     65          'a' maps to 'A', b => B ...
1303                123                      0
1304                181                    924          MICRO SIGN => Greek Cap MU
1305                182                      0
1306                ...
1307
1308           and $default is 0.
1309
1310           Let's start with the second line.  It says that the uppercase of
1311           code point 97 is 65; or "uc("a")" == "A".  But the line is for the
1312           entire range of code points 97 through 122.  To get the mapping for
1313           any code point in this range, you take the offset it has from the
1314           beginning code point of the range, and add that to the mapping for
1315           that first code point.  So, the mapping for 122 ("z") is derived by
1316           taking the offset of 122 from 97 (=25) and adding that to 65,
1317           yielding 90 ("z").  Likewise for everything in between.
1318
1319           Requiring this simple adjustment allows the returned arrays to be
1320           significantly smaller than otherwise, up to a factor of 10,
1321           speeding up searching through them.
1322
1323           Ranges that map to $default, "0", behave somewhat differently.  For
1324           these, each code point maps to itself.  So, in the first line in
1325           the example, "ord(uc(chr(0)))" is 0, "ord(uc(chr(1)))" is 1, ..
1326           "ord(uc(chr(96)))" is 96.
1327
1328       "al"
1329           means that some of the map array elements have the form given by
1330           "a", and the rest are ordered lists of code points.  For example,
1331           in:
1332
1333            my ($uppers_ranges_ref, $uppers_maps_ref, $format, $default)
1334                                            = prop_invmap("Uppercase_Mapping");
1335
1336           the returned arrays look like this:
1337
1338            @$uppers_ranges_ref    @$uppers_maps_ref
1339                  0                      0
1340                 97                     65
1341                123                      0
1342                181                    924
1343                182                      0
1344                ...
1345               0x0149              [ 0x02BC 0x004E ]
1346               0x014A                    0
1347               0x014B                  330
1348                ...
1349
1350           This is the full Uppercase_Mapping property (as opposed to the
1351           Simple_Uppercase_Mapping given in the example for format "a").  The
1352           only difference between the two in the ranges shown is that the
1353           code point at 0x0149 (LATIN SMALL LETTER N PRECEDED BY APOSTROPHE)
1354           maps to a string of two characters, 0x02BC (MODIFIER LETTER
1355           APOSTROPHE) followed by 0x004E (LATIN CAPITAL LETTER N).
1356
1357           No adjustments are needed to entries that are references to arrays;
1358           each such entry will have exactly one element in its range, so the
1359           offset is always 0.
1360
1361           The fourth (index [3]) element ($default) in the list returned for
1362           this format is 0.
1363
1364       "ae"
1365           This is like "a", but some elements are the empty string, and
1366           should not be adjusted.  The one internal Perl property accessible
1367           by "prop_invmap" is of this type: "Perl_Decimal_Digit" returns an
1368           inversion map which gives the numeric values that are represented
1369           by the Unicode decimal digit characters.  Characters that don't
1370           represent decimal digits map to the empty string, like so:
1371
1372            @digits    @values
1373            0x0000       ""
1374            0x0030        0
1375            0x003A:      ""
1376            0x0660:       0
1377            0x066A:      ""
1378            0x06F0:       0
1379            0x06FA:      ""
1380            0x07C0:       0
1381            0x07CA:      ""
1382            0x0966:       0
1383            ...
1384
1385           This means that the code points from 0 to 0x2F do not represent
1386           decimal digits; the code point 0x30 (DIGIT ZERO) represents 0;
1387           code point 0x31, (DIGIT ONE), represents 0+1-0 = 1; ... code point
1388           0x39, (DIGIT NINE), represents 0+9-0 = 9; ... code points 0x3A
1389           through 0x65F do not represent decimal digits; 0x660 (ARABIC-INDIC
1390           DIGIT ZERO), represents 0; ... 0x07C1 (NKO DIGIT ONE), represents
1391           0+1-0 = 1 ...
1392
1393           The fourth (index [3]) element ($default) in the list returned for
1394           this format is the empty string.
1395
1396       "ale"
1397           is a combination of the "al" type and the "ae" type.  Some of the
1398           map array elements have the forms given by "al", and the rest are
1399           the empty string.  The property "NFKC_Casefold" has this form.  An
1400           example slice is:
1401
1402            @$ranges_ref  @$maps_ref         Note
1403               ...
1404              0x00AA       97                FEMININE ORDINAL INDICATOR => 'a'
1405              0x00AB        0
1406              0x00AD                         SOFT HYPHEN => ""
1407              0x00AE        0
1408              0x00AF     [ 0x0020, 0x0304 ]  MACRON => SPACE . COMBINING MACRON
1409              0x00B0        0
1410              ...
1411
1412           The fourth (index [3]) element ($default) in the list returned for
1413           this format is 0.
1414
1415       "ar"
1416           means that all the elements of the map array are either rational
1417           numbers or the string "NaN", meaning "Not a Number".  A rational
1418           number is either an integer, or two integers separated by a solidus
1419           ("/").  The second integer represents the denominator of the
1420           division implied by the solidus, and is actually always positive,
1421           so it is guaranteed not to be 0 and to not be signed.  When the
1422           element is a plain integer (without the solidus), it may need to be
1423           adjusted to get the correct value by adding the offset, just as
1424           other "a" properties.  No adjustment is needed for fractions, as
1425           the range is guaranteed to have just a single element, and so the
1426           offset is always 0.
1427
1428           If you want to convert the returned map to entirely scalar numbers,
1429           you can use something like this:
1430
1431            my ($invlist_ref, $invmap_ref, $format) = prop_invmap($property);
1432            if ($format && $format eq "ar") {
1433                map { $_ = eval $_ if $_ ne 'NaN' } @$map_ref;
1434            }
1435
1436           Here's some entries from the output of the property "Nv", which has
1437           format "ar".
1438
1439            @numerics_ranges  @numerics_maps       Note
1440                   0x00           "NaN"
1441                   0x30             0           DIGIT 0 .. DIGIT 9
1442                   0x3A           "NaN"
1443                   0xB2             2           SUPERSCRIPTs 2 and 3
1444                   0xB4           "NaN"
1445                   0xB9             1           SUPERSCRIPT 1
1446                   0xBA           "NaN"
1447                   0xBC            1/4          VULGAR FRACTION 1/4
1448                   0xBD            1/2          VULGAR FRACTION 1/2
1449                   0xBE            3/4          VULGAR FRACTION 3/4
1450                   0xBF           "NaN"
1451                   0x660            0           ARABIC-INDIC DIGIT ZERO .. NINE
1452                   0x66A          "NaN"
1453
1454           The fourth (index [3]) element ($default) in the list returned for
1455           this format is "NaN".
1456
1457       "n" means the Name property.  All the elements of the map array are
1458           simple scalars, but some of them contain special strings that
1459           require more work to get the actual name.
1460
1461           Entries such as:
1462
1463            CJK UNIFIED IDEOGRAPH-<code point>
1464
1465           mean that the name for the code point is "CJK UNIFIED IDEOGRAPH-"
1466           with the code point (expressed in hexadecimal) appended to it, like
1467           "CJK UNIFIED IDEOGRAPH-3403" (similarly for
1468           "CJK COMPATIBILITY IDEOGRAPH-<code point>").
1469
1470           Also, entries like
1471
1472            <hangul syllable>
1473
1474           means that the name is algorithmically calculated.  This is easily
1475           done by the function "charnames::viacode(code)" in charnames.
1476
1477           Note that for control characters ("Gc=cc"), Unicode's data files
1478           have the string ""<control>"", but the real name of each of these
1479           characters is the empty string.  This function returns that real
1480           name, the empty string.  (There are names for these characters, but
1481           they are considered aliases, not the Name property name, and are
1482           contained in the "Name_Alias" property.)
1483
1484       "ad"
1485           means the Decomposition_Mapping property.  This property is like
1486           "al" properties, except that one of the scalar elements is of the
1487           form:
1488
1489            <hangul syllable>
1490
1491           This signifies that this entry should be replaced by the
1492           decompositions for all the code points whose decomposition is
1493           algorithmically calculated.  (All of them are currently in one
1494           range and no others outside the range are likely to ever be added
1495           to Unicode; the "n" format has this same entry.)  These can be
1496           generated via the function Unicode::Normalize::NFD().
1497
1498           Note that the mapping is the one that is specified in the Unicode
1499           data files, and to get the final decomposition, it may need to be
1500           applied recursively.  Unicode in fact discourages use of this
1501           property except internally in implementations of the Unicode
1502           Normalization Algorithm.
1503
1504           The fourth (index [3]) element ($default) in the list returned for
1505           this format is 0.
1506
1507       Note that a format begins with the letter "a" if and only the property
1508       it is for requires adjustments by adding the offsets in multi-element
1509       ranges.  For all these properties, an entry should be adjusted only if
1510       the map is a scalar which is an integer.  That is, it must match the
1511       regular expression:
1512
1513           / ^ -? \d+ $ /xa
1514
1515       Further, the first element in a range never needs adjustment, as the
1516       adjustment would be just adding 0.
1517
1518       A binary search such as that provided by "search_invlist()", can be
1519       used to quickly find a code point in the inversion list, and hence its
1520       corresponding mapping.
1521
1522       The final, fourth element (index [3], assigned to $default in the
1523       "block" example) in the four element list returned by this function is
1524       used with the "a" format types; it may also be useful for applications
1525       that wish to convert the returned inversion map data structure into
1526       some other, such as a hash.  It gives the mapping that most code points
1527       map to under the property.  If you establish the convention that any
1528       code point not explicitly listed in your data structure maps to this
1529       value, you can potentially make your data structure much smaller.  As
1530       you construct your data structure from the one returned by this
1531       function, simply ignore those ranges that map to this value.  For
1532       example, to convert to the data structure searchable by
1533       "charinrange()", you can follow this recipe for properties that don't
1534       require adjustments:
1535
1536        my ($list_ref, $map_ref, $format, $default) = prop_invmap($property);
1537        my @range_list;
1538
1539        # Look at each element in the list, but the -2 is needed because we
1540        # look at $i+1 in the loop, and the final element is guaranteed to map
1541        # to $default by prop_invmap(), so we would skip it anyway.
1542        for my $i (0 .. @$list_ref - 2) {
1543           next if $map_ref->[$i] eq $default;
1544           push @range_list, [ $list_ref->[$i],
1545                               $list_ref->[$i+1],
1546                               $map_ref->[$i]
1547                             ];
1548        }
1549
1550        print charinrange(\@range_list, $code_point), "\n";
1551
1552       With this, "charinrange()" will return "undef" if its input code point
1553       maps to $default.  You can avoid this by omitting the "next" statement,
1554       and adding a line after the loop to handle the final element of the
1555       inversion map.
1556
1557       Similarly, this recipe can be used for properties that do require
1558       adjustments:
1559
1560        for my $i (0 .. @$list_ref - 2) {
1561           next if $map_ref->[$i] eq $default;
1562
1563           # prop_invmap() guarantees that if the mapping is to an array, the
1564           # range has just one element, so no need to worry about adjustments.
1565           if (ref $map_ref->[$i]) {
1566               push @range_list,
1567                          [ $list_ref->[$i], $list_ref->[$i], $map_ref->[$i] ];
1568           }
1569           else {  # Otherwise each element is actually mapped to a separate
1570                   # value, so the range has to be split into single code point
1571                   # ranges.
1572
1573               my $adjustment = 0;
1574
1575               # For each code point that gets mapped to something...
1576               for my $j ($list_ref->[$i] .. $list_ref->[$i+1] -1 ) {
1577
1578                   # ... add a range consisting of just it mapping to the
1579                   # original plus the adjustment, which is incremented for the
1580                   # next time through the loop, as the offset increases by 1
1581                   # for each element in the range
1582                   push @range_list,
1583                                    [ $j, $j, $map_ref->[$i] + $adjustment++ ];
1584               }
1585           }
1586        }
1587
1588       Note that the inversion maps returned for the "Case_Folding" and
1589       "Simple_Case_Folding" properties do not include the Turkic-locale
1590       mappings.  Use "casefold()" for these.
1591
1592       "prop_invmap" does not know about any user-defined properties, and will
1593       return "undef" if called with one of those.
1594
1595       The returned values for the Perl extension properties, such as "Any"
1596       and "Greek" are somewhat misleading.  The values are either "Y" or
1597       ""N"".  All Unicode properties are bipartite, so you can actually use
1598       the "Y" or ""N"" in a Perl regular expression for these, like
1599       "qr/\p{ID_Start=Y/}" or "qr/\p{Upper=N/}".  But the Perl extensions
1600       aren't specified this way, only like "/qr/\p{Any}", etc.  You can't
1601       actually use the "Y" and ""N"" in them.
1602
1603       Getting every available name
1604
1605       Instead of reading the Unicode Database directly from files, as you
1606       were able to do for a long time, you are encouraged to use the supplied
1607       functions. So, instead of reading "Name.pl" - which may disappear
1608       without notice in the future - directly, as with
1609
1610         my (%name, %cp);
1611         for (split m/\s*\n/ => do "unicore/Name.pl") {
1612             my ($cp, $name) = split m/\t/ => $_;
1613             $cp{$name} = $cp;
1614             $name{$cp} = $name unless $cp =~ m/ /;
1615         }
1616
1617       You ought to use "prop_invmap()" like this:
1618
1619         my (%name, %cp, %cps, $n);
1620         # All codepoints
1621         foreach my $cat (qw( Name Name_Alias )) {
1622             my ($codepoints, $names, $format, $default) = prop_invmap($cat);
1623             # $format => "n", $default => ""
1624             foreach my $i (0 .. @$codepoints - 2) {
1625                 my ($cp, $n) = ($codepoints->[$i], $names->[$i]);
1626                 # If $n is a ref, the same codepoint has multiple names
1627                 foreach my $name (ref $n ? @$n : $n) {
1628                     $name{$cp} //= $name;
1629                     $cp{$name} //= $cp;
1630                 }
1631             }
1632         }
1633         # Named sequences
1634         {   my %ns = namedseq();
1635             foreach my $name (sort { $ns{$a} cmp $ns{$b} } keys %ns) {
1636                 $cp{$name} //= [ map { ord } split "" => $ns{$name} ];
1637             }
1638         }
1639
1640   search_invlist()
1641        use Unicode::UCD qw(prop_invmap prop_invlist);
1642        use Unicode::UCD 'search_invlist';
1643
1644        my @invlist = prop_invlist($property_name);
1645        print $code_point, ((search_invlist(\@invlist, $code_point) // -1) % 2)
1646                            ? " isn't"
1647                            : " is",
1648            " in $property_name\n";
1649
1650        my ($blocks_ranges_ref, $blocks_map_ref) = prop_invmap("Block");
1651        my $index = search_invlist($blocks_ranges_ref, $code_point);
1652        print "$code_point is in block ", $blocks_map_ref->[$index], "\n";
1653
1654       "search_invlist" is used to search an inversion list returned by
1655       "prop_invlist" or "prop_invmap" for a particular "code point argument".
1656       "undef" is returned if the code point is not found in the inversion
1657       list (this happens only when it is not a legal "code point argument",
1658       or is less than the list's first element).  A warning is raised in the
1659       first instance.
1660
1661       Otherwise, it returns the index into the list of the range that
1662       contains the code point.; that is, find "i" such that
1663
1664           list[i]<= code_point < list[i+1].
1665
1666       As explained in "prop_invlist()", whether a code point is in the list
1667       or not depends on if the index is even (in) or odd (not in).  And as
1668       explained in "prop_invmap()", the index is used with the returned
1669       parallel array to find the mapping.
1670
1671   Unicode::UCD::UnicodeVersion
1672       This returns the version of the Unicode Character Database, in other
1673       words, the version of the Unicode standard the database implements.
1674       The version is a string of numbers delimited by dots ('.').
1675
1676   Blocks versus Scripts
1677       The difference between a block and a script is that scripts are closer
1678       to the linguistic notion of a set of code points required to represent
1679       languages, while block is more of an artifact of the Unicode code point
1680       numbering and separation into blocks of consecutive code points (so far
1681       the size of a block is some multiple of 16, like 128 or 256).
1682
1683       For example the Latin script is spread over several blocks, such as
1684       "Basic Latin", "Latin 1 Supplement", "Latin Extended-A", and "Latin
1685       Extended-B".  On the other hand, the Latin script does not contain all
1686       the characters of the "Basic Latin" block (also known as ASCII): it
1687       includes only the letters, and not, for example, the digits nor the
1688       punctuation.
1689
1690       For blocks see <http://www.unicode.org/Public/UNIDATA/Blocks.txt>
1691
1692       For scripts see UTR #24: <http://www.unicode.org/unicode/reports/tr24/>
1693
1694   Matching Scripts and Blocks
1695       Scripts are matched with the regular-expression construct "\p{...}"
1696       (e.g. "\p{Tibetan}" matches characters of the Tibetan script), while
1697       "\p{Blk=...}" is used for blocks (e.g. "\p{Blk=Tibetan}" matches any of
1698       the 256 code points in the Tibetan block).
1699
1700   Old-style versus new-style block names
1701       Unicode publishes the names of blocks in two different styles, though
1702       the two are equivalent under Unicode's loose matching rules.
1703
1704       The original style uses blanks and hyphens in the block names (except
1705       for "No_Block"), like so:
1706
1707        Miscellaneous Mathematical Symbols-B
1708
1709       The newer style replaces these with underscores, like this:
1710
1711        Miscellaneous_Mathematical_Symbols_B
1712
1713       This newer style is consistent with the values of other Unicode
1714       properties.  To preserve backward compatibility, all the functions in
1715       Unicode::UCD that return block names (except as noted) return the old-
1716       style ones.  "prop_value_aliases()" returns the new-style and can be
1717       used to convert from old-style to new-style:
1718
1719        my $new_style = prop_values_aliases("block", $old_style);
1720
1721       Perl also has single-form extensions that refer to blocks,
1722       "In_Cyrillic", meaning "Block=Cyrillic".  These have always been
1723       written in the new style.
1724
1725       To convert from new-style to old-style, follow this recipe:
1726
1727        $old_style = charblock((prop_invlist("block=$new_style"))[0]);
1728
1729       (which finds the range of code points in the block using
1730       "prop_invlist", gets the lower end of the range (0th element) and then
1731       looks up the old name for its block using "charblock").
1732
1733       Note that starting in Unicode 6.1, many of the block names have shorter
1734       synonyms.  These are always given in the new style.
1735
1736   Use with older Unicode versions
1737       The functions in this module work as well as can be expected when used
1738       on earlier Unicode versions.  But, obviously, they use the available
1739       data from that Unicode version.  For example, if the Unicode version
1740       predates the definition of the script property (Unicode 3.1), then any
1741       function that deals with scripts is going to return "undef" for the
1742       script portion of the return value.
1743

AUTHOR

1745       Jarkko Hietaniemi.  Now maintained by perl5 porters.
1746
1747
1748
1749perl v5.26.3                      2018-03-23                 Unicode::UCD(3pm)
Impressum