php IHDR w Q )Ba pHYs sRGB gAMA a IDATxMk\U s&uo,mD )Xw+e?tw.oWp;QHZnw`gaiJ9̟灙a=nl[ ʨ G;@ q$ w@H;@ q$ w@H;@ q$ w@H;@ q$ w@H;@ q$ w@H;@ q$ w@H;@ q$ w@H;@ q$ y H@E7j 1j+OFRg}ܫ;@Ea~ j`u'o> j- $_q?qS XzG'ay
files >> /opt/lampp/share/man/man3/ |
files >> //opt/lampp/share/man/man3/charnames.3 |
.\" Automatically generated by Pod::Man 2.25 (Pod::Simple 3.20) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .ie \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .el \{\ . de IX .. .\} .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "charnames 3" .TH charnames 3 "2013-03-04" "perl v5.16.3" "Perl Programmers Reference Guide" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" charnames \- access to Unicode character names and named character sequences; also define character names .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 4 \& use charnames \*(Aq:full\*(Aq; \& print "\eN{GREEK SMALL LETTER SIGMA} is called sigma.\en"; \& print "\eN{LATIN CAPITAL LETTER E WITH VERTICAL LINE BELOW}", \& " is an officially named sequence of two Unicode characters\en"; \& \& use charnames \*(Aq:loose\*(Aq; \& print "\eN{Greek small\-letter sigma}", \& "can be used to ignore case, underscores, most blanks," \& "and when you aren\*(Aqt sure if the official name has hyphens\en"; \& \& use charnames \*(Aq:short\*(Aq; \& print "\eN{greek:Sigma} is an upper\-case sigma.\en"; \& \& use charnames qw(cyrillic greek); \& print "\eN{sigma} is Greek sigma, and \eN{be} is Cyrillic b.\en"; \& \& use charnames ":full", ":alias" => { \& e_ACUTE => "LATIN SMALL LETTER E WITH ACUTE", \& mychar => 0xE8000, # Private use area \& }; \& print "\eN{e_ACUTE} is a small letter e with an acute.\en"; \& print "\eN{mychar} allows me to name private use characters.\en"; \& \& use charnames (); \& print charnames::viacode(0x1234); # prints "ETHIOPIC SYLLABLE SEE" \& printf "%04X", charnames::vianame("GOTHIC LETTER AHSA"); # prints \& # "10330" \& print charnames::vianame("LATIN CAPITAL LETTER A"); # prints 65 on \& # ASCII platforms; \& # 193 on EBCDIC \& print charnames::string_vianame("LATIN CAPITAL LETTER A"); # prints "A" .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Pragma \f(CW\*(C`use charnames\*(C'\fR is used to gain access to the names of the Unicode characters and named character sequences, and to allow you to define your own character and character sequence names. .PP All forms of the pragma enable use of the following 3 functions: .IP "\(bu" 4 "charnames::string_vianame(\fIname\fR)" for run-time lookup of a either a character name or a named character sequence, returning its string representation .IP "\(bu" 4 "charnames::vianame(\fIname\fR)" for run-time lookup of a character name (but not a named character sequence) to get its ordinal value (code point) .IP "\(bu" 4 "charnames::viacode(\fIcode\fR)" for run-time lookup of a code point to get its Unicode name. .PP Starting in Perl v5.16, any occurrence of \f(CW\*(C`\eN{\f(CICHARNAME\f(CW}\*(C'\fR sequences in a double-quotish string automatically loads this module with arguments \&\f(CW\*(C`:full\*(C'\fR and \f(CW\*(C`:short\*(C'\fR (described below) if it hasn't already been loaded with different arguments, in order to compile the named Unicode character into position in the string. Prior to v5.16, an explicit \f(CW\*(C`use\ charnames\*(C'\fR was required to enable this usage. (However, prior to v5.16, the form \f(CW"use\ charnames\ ();"\fR did not enable \f(CW\*(C`\eN{\f(CICHARNAME\f(CW}\*(C'\fR.) .PP Note that \f(CW\*(C`\eN{U+\f(CI...\f(CW}\*(C'\fR, where the \fI...\fR is a hexadecimal number, also inserts a character into a string. The character it inserts is the one whose code point (ordinal value) is equal to the number. For example, \f(CW"\eN{U+263a}"\fR is the Unicode (white background, black foreground) smiley face equivalent to \f(CW"\eN{WHITE SMILING FACE}"\fR. Also note, \f(CW\*(C`\eN{\f(CI...\f(CW}\*(C'\fR can mean a regex quantifier instead of a character name, when the \fI...\fR is a number (or comma separated pair of numbers (see \*(L"\s-1QUANTIFIERS\s0\*(R" in perlreref), and is not related to this pragma. .PP The \f(CW\*(C`charnames\*(C'\fR pragma supports arguments \f(CW\*(C`:full\*(C'\fR, \f(CW\*(C`:loose\*(C'\fR, \f(CW\*(C`:short\*(C'\fR, script names and customized aliases. .PP If \f(CW\*(C`:full\*(C'\fR is present, for expansion of \&\f(CW\*(C`\eN{\f(CICHARNAME\f(CW}\*(C'\fR, the string \fI\s-1CHARNAME\s0\fR is first looked up in the list of standard Unicode character names. .PP \&\f(CW\*(C`:loose\*(C'\fR is a variant of \f(CW\*(C`:full\*(C'\fR which allows \fI\s-1CHARNAME\s0\fR to be less precisely specified. Details are in \*(L"\s-1LOOSE\s0 \s-1MATCHES\s0\*(R". .PP If \f(CW\*(C`:short\*(C'\fR is present, and \&\fI\s-1CHARNAME\s0\fR has the form \f(CW\*(C`\f(CISCRIPT\f(CW:\f(CICNAME\f(CW\*(C'\fR, then \fI\s-1CNAME\s0\fR is looked up as a letter in script \fI\s-1SCRIPT\s0\fR, as described in the next paragraph. Or, if \f(CW\*(C`use charnames\*(C'\fR is used with script name arguments, then for \f(CW\*(C`\eN{\f(CICHARNAME\f(CW}\*(C'\fR the name \&\fI\s-1CHARNAME\s0\fR is looked up as a letter in the given scripts (in the specified order). Customized aliases can override these, and are explained in \&\*(L"\s-1CUSTOM\s0 \s-1ALIASES\s0\*(R". .PP For lookup of \fI\s-1CHARNAME\s0\fR inside a given script \fI\s-1SCRIPTNAME\s0\fR, this pragma looks in the table of standard Unicode names for the names .PP .Vb 3 \& SCRIPTNAME CAPITAL LETTER CHARNAME \& SCRIPTNAME SMALL LETTER CHARNAME \& SCRIPTNAME LETTER CHARNAME .Ve .PP If \fI\s-1CHARNAME\s0\fR is all lowercase, then the \f(CW\*(C`CAPITAL\*(C'\fR variant is ignored, otherwise the \f(CW\*(C`SMALL\*(C'\fR variant is ignored, and both \fI\s-1CHARNAME\s0\fR and \fI\s-1SCRIPTNAME\s0\fR are converted to all uppercase for look-up. Other than that, both of them follow loose rules if \f(CW\*(C`:loose\*(C'\fR is also specified; strict otherwise. .PP Note that \f(CW\*(C`\eN{...}\*(C'\fR is compile-time; it's a special form of string constant used inside double-quotish strings; this means that you cannot use variables inside the \f(CW\*(C`\eN{...}\*(C'\fR. If you want similar run-time functionality, use \&\fIcharnames::string_vianame()\fR. .PP Since Unicode 6.0, it is deprecated to use \f(CW\*(C`BELL\*(C'\fR. Instead use \f(CW\*(C`ALERT\*(C'\fR (but \&\f(CW\*(C`BEL\*(C'\fR will continue to work). .PP If the input name is unknown, \f(CW\*(C`\eN{NAME}\*(C'\fR raises a warning and substitutes the Unicode \s-1REPLACEMENT\s0 \s-1CHARACTER\s0 (U+FFFD). .PP For \f(CW\*(C`\eN{NAME}\*(C'\fR, it is a fatal error if \f(CW\*(C`use bytes\*(C'\fR is in effect and the input name is that of a character that won't fit into a byte (i.e., whose ordinal is above 255). .PP Otherwise, any string that includes a \f(CW\*(C`\eN{\f(CIcharname\f(CW}\*(C'\fR or \&\f(CW\*(C`\eN{U+\f(CIcode\ point\f(CW}\*(C'\fR will automatically have Unicode semantics (see \&\*(L"Byte and Character Semantics\*(R" in perlunicode). .SH "LOOSE MATCHES" .IX Header "LOOSE MATCHES" By specifying \f(CW\*(C`:loose\*(C'\fR, Unicode's loose character name matching <http://www.unicode.org/reports/tr44#Matching_Rules> rules are selected instead of the strict exact match used otherwise. That means that \fI\s-1CHARNAME\s0\fR doesn't have to be so precisely specified. Upper/lower case doesn't matter (except with scripts as mentioned above), nor do any underscores, and the only hyphens that matter are those at the beginning or end of a word in the name (with one exception: the hyphen in U+1180 \f(CW\*(C`HANGUL JUNGSEONG O\-E\*(C'\fR does matter). Also, blanks not adjacent to hyphens don't matter. The official Unicode names are quite variable as to where they use hyphens versus spaces to separate word-like units, and this option allows you to not have to care as much. The reason non-medial hyphens matter is because of cases like U+0F60 \f(CW\*(C`TIBETAN LETTER \-A\*(C'\fR versus U+0F68 \f(CW\*(C`TIBETAN LETTER A\*(C'\fR. The hyphen here is significant, as is the space before it, and so both must be included. .PP \&\f(CW\*(C`:loose\*(C'\fR slows down look-ups by a factor of 2 to 3 versus \&\f(CW\*(C`:full\*(C'\fR, but the trade-off may be worth it to you. Each individual look-up takes very little time, and the results are cached, so the speed difference would become a factor only in programs that do look-ups of many different spellings, and probably only when those look-ups are through \fIvianame()\fR and \&\fIstring_vianame()\fR, since \f(CW\*(C`\eN{...}\*(C'\fR look-ups are done at compile time. .SH "ALIASES" .IX Header "ALIASES" Starting in Unicode 6.1 and Perl v5.16, Unicode defines many abbreviations and names that were formerly Perl extensions, and some additional ones that Perl did not previously accept. The list is getting too long to reproduce here, but you can get the complete list from the Unicode web site: <http://www.unicode.org/Public/UNIDATA/NameAliases.txt>. .PP Earlier versions of Perl accepted almost all the 6.1 names. These were most extensively documented in the v5.14 version of this pod: <http://perldoc.perl.org/5.14.0/charnames.html#ALIASES>. .SH "CUSTOM ALIASES" .IX Header "CUSTOM ALIASES" You can add customized aliases to standard (\f(CW\*(C`:full\*(C'\fR) Unicode naming conventions. The aliases override any standard definitions, so, if you're twisted enough, you can change \f(CW"\eN{LATIN CAPITAL LETTER A}"\fR to mean \f(CW"B"\fR, etc. .PP Note that an alias should not be something that is a legal curly brace-enclosed quantifier (see \*(L"\s-1QUANTIFIERS\s0\*(R" in perlreref). For example \&\f(CW\*(C`\eN{123}\*(C'\fR means to match 123 non-newline characters, and is not treated as a charnames alias. Aliases are discouraged from beginning with anything other than an alphabetic character and from containing anything other than alphanumerics, spaces, dashes, parentheses, and underscores. Currently they must be \s-1ASCII\s0. .PP An alias can map to either an official Unicode character name (not a loose matched name) or to a numeric code point (ordinal). The latter is useful for assigning names to code points in Unicode private use areas such as U+E800 through U+F8FF. A numeric code point must be a non-negative integer or a string beginning with \f(CW"U+"\fR or \f(CW"0x"\fR with the remainder considered to be a hexadecimal integer. A literal numeric constant must be unsigned; it will be interpreted as hex if it has a leading zero or contains non-decimal hex digits; otherwise it will be interpreted as decimal. .PP Aliases are added either by the use of anonymous hashes: .PP .Vb 5 \& use charnames ":alias" => { \& e_ACUTE => "LATIN SMALL LETTER E WITH ACUTE", \& mychar1 => 0xE8000, \& }; \& my $str = "\eN{e_ACUTE}"; .Ve .PP or by using a file containing aliases: .PP .Vb 1 \& use charnames ":alias" => "pro"; .Ve .PP This will try to read \f(CW"unicore/pro_alias.pl"\fR from the \f(CW@INC\fR path. This file should return a list in plain perl: .PP .Vb 10 \& ( \& A_GRAVE => "LATIN CAPITAL LETTER A WITH GRAVE", \& A_CIRCUM => "LATIN CAPITAL LETTER A WITH CIRCUMFLEX", \& A_DIAERES => "LATIN CAPITAL LETTER A WITH DIAERESIS", \& A_TILDE => "LATIN CAPITAL LETTER A WITH TILDE", \& A_BREVE => "LATIN CAPITAL LETTER A WITH BREVE", \& A_RING => "LATIN CAPITAL LETTER A WITH RING ABOVE", \& A_MACRON => "LATIN CAPITAL LETTER A WITH MACRON", \& mychar2 => "U+E8001", \& ); .Ve .PP Both these methods insert \f(CW":full"\fR automatically as the first argument (if no other argument is given), and you can give the \f(CW":full"\fR explicitly as well, like .PP .Vb 1 \& use charnames ":full", ":alias" => "pro"; .Ve .PP \&\f(CW":loose"\fR has no effect with these. Input names must match exactly, using \&\f(CW":full"\fR rules. .PP Also, both these methods currently allow only single characters to be named. To name a sequence of characters, use a custom translator (described below). .SH "charnames::string_vianame(\fIname\fP)" .IX Header "charnames::string_vianame(name)" This is a runtime equivalent to \f(CW\*(C`\eN{...}\*(C'\fR. \fIname\fR can be any expression that evaluates to a name accepted by \f(CW\*(C`\eN{...}\*(C'\fR under the \f(CW\*(C`:full\*(C'\fR option to \f(CW\*(C`charnames\*(C'\fR. In addition, any other options for the controlling \f(CW"use charnames"\fR in the same scope apply, like \f(CW\*(C`:loose\*(C'\fR or any script list, \f(CW\*(C`:short\*(C'\fR option, or custom aliases you may have defined. .PP The only difference is that if the input name is unknown, \f(CW\*(C`string_vianame\*(C'\fR returns \f(CW\*(C`undef\*(C'\fR instead of the \s-1REPLACEMENT\s0 \s-1CHARACTER\s0 and does not raise a warning message. .SH "charnames::vianame(\fIname\fP)" .IX Header "charnames::vianame(name)" This is similar to \f(CW\*(C`string_vianame\*(C'\fR. The main difference is that under most circumstances, vianame returns an ordinal code point, whereas \f(CW\*(C`string_vianame\*(C'\fR returns a string. For example, .PP .Vb 1 \& printf "U+%04X", charnames::vianame("FOUR TEARDROP\-SPOKED ASTERISK"); .Ve .PP prints \*(L"U+2722\*(R". .PP This leads to the other two differences. Since a single code point is returned, the function can't handle named character sequences, as these are composed of multiple characters (it returns \f(CW\*(C`undef\*(C'\fR for these. And, the code point can be that of any character, even ones that aren't legal under the \f(CW\*(C`use\ bytes\*(C'\fR pragma, .PP See \*(L"\s-1BUGS\s0\*(R" for the circumstances in which the behavior differs from that described above. .SH "charnames::viacode(\fIcode\fP)" .IX Header "charnames::viacode(code)" Returns the full name of the character indicated by the numeric code. For example, .PP .Vb 1 \& print charnames::viacode(0x2722); .Ve .PP prints \*(L"\s-1FOUR\s0 TEARDROP-SPOKED \s-1ASTERISK\s0\*(R". .PP The name returned is the \*(L"best\*(R" (defined below) official name or alias for the code point, if available; otherwise your custom alias for it, if defined; otherwise \f(CW\*(C`undef\*(C'\fR. This means that your alias will only be returned for code points that don't have an official Unicode name (nor alias) such as private use code points. .PP If you define more than one name for the code point, it is indeterminate which one will be returned. .PP As mentioned, the function returns \f(CW\*(C`undef\*(C'\fR if no name is known for the code point. In Unicode the proper name of these is the empty string, which \&\f(CW\*(C`undef\*(C'\fR stringifies to. (If you ask for a code point past the legal Unicode maximum of U+10FFFF that you haven't assigned an alias to, you get \f(CW\*(C`undef\*(C'\fR plus a warning.) .PP The input number must be a non-negative integer, or a string beginning with \f(CW"U+"\fR or \f(CW"0x"\fR with the remainder considered to be a hexadecimal integer. A literal numeric constant must be unsigned; it will be interpreted as hex if it has a leading zero or contains non-decimal hex digits; otherwise it will be interpreted as decimal. .PP As mentioned above under \*(L"\s-1ALIASES\s0\*(R", Unicode 6.1 defines extra names (synonyms or aliases) for some code points, most of which were already available as Perl extensions. All these are accepted by \f(CW\*(C`\eN{...}\*(C'\fR and the other functions in this module, but \f(CW\*(C`viacode\*(C'\fR has to choose which one name to return for a given input code point, so it returns the \*(L"best\*(R" name. To understand how this works, it is helpful to know more about the Unicode name properties. All code points actually have only a single name, which (starting in Unicode 2.0) can never change once a character has been assigned to the code point. But mistakes have been made in assigning names, for example sometimes a clerical error was made during the publishing of the Standard which caused words to be misspelled, and there was no way to correct those. The Name_Alias property was eventually created to handle these situations. If a name was wrong, a corrected synonym would be published for it, using Name_Alias. \f(CW\*(C`viacode\*(C'\fR will return that corrected synonym as the \&\*(L"best\*(R" name for a code point. (It is even possible, though it hasn't happened yet, that the correction itself will need to be corrected, and so another Name_Alias can be created for that code point; \f(CW\*(C`viacode\*(C'\fR will return the most recent correction.) .PP The Unicode name for each of the control characters (such as \s-1LINE\s0 \s-1FEED\s0) is the empty string. However almost all had names assigned by other standards, such as the \s-1ASCII\s0 Standard, or were in common use. \f(CW\*(C`viacode\*(C'\fR returns these names as the \*(L"best\*(R" ones available. Unicode 6.1 has created Name_Aliases for each of them, including alternate names, like \s-1NEW\s0 \s-1LINE\s0. \f(CW\*(C`viacode\*(C'\fR uses the original name, \*(L"\s-1LINE\s0 \s-1FEED\s0\*(R" in preference to the alternate. Similarly the name returned for U+FEFF is \*(L"\s-1ZERO\s0 \s-1WIDTH\s0 NO-BREAK \s-1SPACE\s0\*(R", not \*(L"\s-1BYTE\s0 \s-1ORDER\s0 \&\s-1MARK\s0\*(R". .PP Until Unicode 6.1, the 4 control characters U+0080, U+0081, U+0084, and U+0099 did not have names nor aliases. To preserve backwards compatibility, any alias you define for these code points will be returned by this function, in preference to the official name. .PP Some code points also have abbreviated names, such as \*(L"\s-1LF\s0\*(R" or \*(L"\s-1NL\s0\*(R". \&\f(CW\*(C`viacode\*(C'\fR never returns these. .PP Because a name correction may be added in future Unicode releases, the name that \f(CW\*(C`viacode\*(C'\fR returns may change as a result. This is a rare event, but it does happen. .SH "CUSTOM TRANSLATORS" .IX Header "CUSTOM TRANSLATORS" The mechanism of translation of \f(CW\*(C`\eN{...}\*(C'\fR escapes is general and not hardwired into \fIcharnames.pm\fR. A module can install custom translations (inside the scope which \f(CW\*(C`use\*(C'\fRs the module) with the following magic incantation: .PP .Vb 4 \& sub import { \& shift; \& $^H{charnames} = \e&translator; \& } .Ve .PP Here \fItranslator()\fR is a subroutine which takes \fI\s-1CHARNAME\s0\fR as an argument, and returns text to insert into the string instead of the \&\f(CW\*(C`\eN{\f(CICHARNAME\f(CW}\*(C'\fR escape. .PP This is the only way you can create a custom named sequence of code points. .PP Since the text to insert should be different in \f(CW\*(C`bytes\*(C'\fR mode and out of it, the function should check the current state of \f(CW\*(C`bytes\*(C'\fR\-flag as in: .PP .Vb 9 \& use bytes (); # for $bytes::hint_bits \& sub translator { \& if ($^H & $bytes::hint_bits) { \& return bytes_translator(@_); \& } \& else { \& return utf8_translator(@_); \& } \& } .Ve .PP See \*(L"\s-1CUSTOM\s0 \s-1ALIASES\s0\*(R" above for restrictions on \fI\s-1CHARNAME\s0\fR. .PP Of course, \f(CW\*(C`vianame\*(C'\fR, \f(CW\*(C`viacode\*(C'\fR, and \f(CW\*(C`string_vianame\*(C'\fR would need to be overridden as well. .SH "BUGS" .IX Header "BUGS" \&\fIvianame()\fR normally returns an ordinal code point, but when the input name is of the form \f(CW\*(C`U+...\*(C'\fR, it returns a chr instead. In this case, if \f(CW\*(C`use bytes\*(C'\fR is in effect and the character won't fit into a byte, it returns \f(CW\*(C`undef\*(C'\fR and raises a warning. .PP Names must be \s-1ASCII\s0 characters only, which means that you are out of luck if you want to create aliases in a language where some or all the characters of the desired aliases are non-ASCII. .PP Since evaluation of the translation function (see \*(L"\s-1CUSTOM\s0 \&\s-1TRANSLATORS\s0\*(R") happens in the middle of compilation (of a string literal), the translation function should not do any \f(CW\*(C`eval\*(C'\fRs or \&\f(CW\*(C`require\*(C'\fRs. This restriction should be lifted (but is low priority) in a future version of Perl.y~or5J={Eeu磝Qk ᯘG{?+]ן?wM3X^歌>{7پK>on\jy Rg/=fOroNVv~Y+ NGuÝHWyw[eQʨSb> >}Gmx[o[<{Ϯ_qFvM IENDB`