Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v8plus / man / man3 / charnames.3
CommitLineData
920dae64
AT
1.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32
2.\"
3.\" Standard preamble:
4.\" ========================================================================
5.de Sh \" Subsection heading
6.br
7.if t .Sp
8.ne 5
9.PP
10\fB\\$1\fR
11.PP
12..
13.de Sp \" Vertical space (when we can't use .PP)
14.if t .sp .5v
15.if n .sp
16..
17.de Vb \" Begin verbatim text
18.ft CW
19.nf
20.ne \\$1
21..
22.de Ve \" End verbatim text
23.ft R
24.fi
25..
26.\" Set up some character translations and predefined strings. \*(-- will
27.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
28.\" double quote, and \*(R" will give a right double quote. | will give a
29.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
30.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
31.\" expand to `' in nroff, nothing in troff, for use with C<>.
32.tr \(*W-|\(bv\*(Tr
33.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
34.ie n \{\
35. ds -- \(*W-
36. ds PI pi
37. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
38. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
39. ds L" ""
40. ds R" ""
41. ds C` ""
42. ds C' ""
43'br\}
44.el\{\
45. ds -- \|\(em\|
46. ds PI \(*p
47. ds L" ``
48. ds R" ''
49'br\}
50.\"
51.\" If the F register is turned on, we'll generate index entries on stderr for
52.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
53.\" entries marked with X<> in POD. Of course, you'll have to process the
54.\" output yourself in some meaningful fashion.
55.if \nF \{\
56. de IX
57. tm Index:\\$1\t\\n%\t"\\$2"
58..
59. nr % 0
60. rr F
61.\}
62.\"
63.\" For nroff, turn off justification. Always turn off hyphenation; it makes
64.\" way too many mistakes in technical documents.
65.hy 0
66.if n .na
67.\"
68.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
69.\" Fear. Run. Save yourself. No user-serviceable parts.
70. \" fudge factors for nroff and troff
71.if n \{\
72. ds #H 0
73. ds #V .8m
74. ds #F .3m
75. ds #[ \f1
76. ds #] \fP
77.\}
78.if t \{\
79. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
80. ds #V .6m
81. ds #F 0
82. ds #[ \&
83. ds #] \&
84.\}
85. \" simple accents for nroff and troff
86.if n \{\
87. ds ' \&
88. ds ` \&
89. ds ^ \&
90. ds , \&
91. ds ~ ~
92. ds /
93.\}
94.if t \{\
95. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
96. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
97. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
98. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
99. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
100. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
101.\}
102. \" troff and (daisy-wheel) nroff accents
103.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
104.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
105.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
106.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
107.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
108.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
109.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
110.ds ae a\h'-(\w'a'u*4/10)'e
111.ds Ae A\h'-(\w'A'u*4/10)'E
112. \" corrections for vroff
113.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
114.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
115. \" for low resolution devices (crt and lpr)
116.if \n(.H>23 .if \n(.V>19 \
117\{\
118. ds : e
119. ds 8 ss
120. ds o a
121. ds d- d\h'-1'\(ga
122. ds D- D\h'-1'\(hy
123. ds th \o'bp'
124. ds Th \o'LP'
125. ds ae ae
126. ds Ae AE
127.\}
128.rm #[ #] #H #V #F C
129.\" ========================================================================
130.\"
131.IX Title "charnames 3"
132.TH charnames 3 "2001-09-21" "perl v5.8.8" "Perl Programmers Reference Guide"
133.SH "NAME"
134charnames \- define character names for \f(CW\*(C`\eN{named}\*(C'\fR string literal escapes
135.SH "SYNOPSIS"
136.IX Header "SYNOPSIS"
137.Vb 2
138\& use charnames ':full';
139\& print "\eN{GREEK SMALL LETTER SIGMA} is called sigma.\en";
140.Ve
141.PP
142.Vb 2
143\& use charnames ':short';
144\& print "\eN{greek:Sigma} is an upper-case sigma.\en";
145.Ve
146.PP
147.Vb 2
148\& use charnames qw(cyrillic greek);
149\& print "\eN{sigma} is Greek sigma, and \eN{be} is Cyrillic b.\en";
150.Ve
151.PP
152.Vb 4
153\& use charnames ":full", ":alias" => {
154\& e_ACUTE => "LATIN SMALL LETTER E WITH ACUTE",
155\& };
156\& print "\eN{e_ACUTE} is a small letter e with an acute.\en";
157.Ve
158.PP
159.Vb 3
160\& use charnames ();
161\& print charnames::viacode(0x1234); # prints "ETHIOPIC SYLLABLE SEE"
162\& printf "%04X", charnames::vianame("GOTHIC LETTER AHSA"); # prints "10330"
163.Ve
164.SH "DESCRIPTION"
165.IX Header "DESCRIPTION"
166Pragma \f(CW\*(C`use charnames\*(C'\fR supports arguments \f(CW\*(C`:full\*(C'\fR, \f(CW\*(C`:short\*(C'\fR, script
167names and customized aliases. If \f(CW\*(C`:full\*(C'\fR is present, for expansion of
168\&\f(CW\*(C`\eN{CHARNAME}\*(C'\fR, the string \f(CW\*(C`CHARNAME\*(C'\fR is first looked up in the list of
169standard Unicode character names. If \f(CW\*(C`:short\*(C'\fR is present, and
170\&\f(CW\*(C`CHARNAME\*(C'\fR has the form \f(CW\*(C`SCRIPT:CNAME\*(C'\fR, then \f(CW\*(C`CNAME\*(C'\fR is looked up
171as a letter in script \f(CW\*(C`SCRIPT\*(C'\fR. If pragma \f(CW\*(C`use charnames\*(C'\fR is used
172with script name arguments, then for \f(CW\*(C`\eN{CHARNAME}\*(C'\fR the name
173\&\f(CW\*(C`CHARNAME\*(C'\fR is looked up as a letter in the given scripts (in the
174specified order). Customized aliases are explained in \*(L"\s-1CUSTOM\s0 \s-1ALIASES\s0\*(R".
175.PP
176For lookup of \f(CW\*(C`CHARNAME\*(C'\fR inside a given script \f(CW\*(C`SCRIPTNAME\*(C'\fR
177this pragma looks for the names
178.PP
179.Vb 3
180\& SCRIPTNAME CAPITAL LETTER CHARNAME
181\& SCRIPTNAME SMALL LETTER CHARNAME
182\& SCRIPTNAME LETTER CHARNAME
183.Ve
184.PP
185in the table of standard Unicode names. If \f(CW\*(C`CHARNAME\*(C'\fR is lowercase,
186then the \f(CW\*(C`CAPITAL\*(C'\fR variant is ignored, otherwise the \f(CW\*(C`SMALL\*(C'\fR variant
187is ignored.
188.PP
189Note that \f(CW\*(C`\eN{...}\*(C'\fR is compile\-time, it's a special form of string
190constant used inside double-quoted strings: in other words, you cannot
191use variables inside the \f(CW\*(C`\eN{...}\*(C'\fR. If you want similar run-time
192functionality, use \fIcharnames::vianame()\fR.
193.PP
194For the C0 and C1 control characters (U+0000..U+001F, U+0080..U+009F)
195as of Unicode 3.1, there are no official Unicode names but you can use
196instead the \s-1ISO\s0 6429 names (\s-1LINE\s0 \s-1FEED\s0, \s-1ESCAPE\s0, and so forth). In
197Unicode 3.2 (as of Perl 5.8) some naming changes take place \s-1ISO\s0 6429
198has been updated, see \*(L"\s-1ALIASES\s0\*(R". Also note that the U+UU80, U+0081,
199U+0084, and U+0099 do not have names even in \s-1ISO\s0 6429.
200.PP
201Since the Unicode standard uses \*(L"U+HHHH\*(R", so can you: \*(L"\eN{U+263a}\*(R"
202is the Unicode smiley face, or \*(L"\eN{\s-1WHITE\s0 \s-1SMILING\s0 \s-1FACE\s0}\*(R".
203.SH "CUSTOM TRANSLATORS"
204.IX Header "CUSTOM TRANSLATORS"
205The mechanism of translation of \f(CW\*(C`\eN{...}\*(C'\fR escapes is general and not
206hardwired into \fIcharnames.pm\fR. A module can install custom
207translations (inside the scope which \f(CW\*(C`use\*(C'\fRs the module) with the
208following magic incantation:
209.PP
210.Vb 6
211\& use charnames (); # for $charnames::hint_bits
212\& sub import {
213\& shift;
214\& $^H |= $charnames::hint_bits;
215\& $^H{charnames} = \e&translator;
216\& }
217.Ve
218.PP
219Here \fItranslator()\fR is a subroutine which takes \f(CW\*(C`CHARNAME\*(C'\fR as an
220argument, and returns text to insert into the string instead of the
221\&\f(CW\*(C`\eN{CHARNAME}\*(C'\fR escape. Since the text to insert should be different
222in \f(CW\*(C`bytes\*(C'\fR mode and out of it, the function should check the current
223state of \f(CW\*(C`bytes\*(C'\fR\-flag as in:
224.PP
225.Vb 9
226\& use bytes (); # for $bytes::hint_bits
227\& sub translator {
228\& if ($^H & $bytes::hint_bits) {
229\& return bytes_translator(@_);
230\& }
231\& else {
232\& return utf8_translator(@_);
233\& }
234\& }
235.Ve
236.SH "CUSTOM ALIASES"
237.IX Header "CUSTOM ALIASES"
238This version of charnames supports three mechanisms of adding local
239or customized aliases to standard Unicode naming conventions (:full)
240.Sh "Anonymous hashes"
241.IX Subsection "Anonymous hashes"
242.Vb 4
243\& use charnames ":full", ":alias" => {
244\& e_ACUTE => "LATIN SMALL LETTER E WITH ACUTE",
245\& };
246\& my $str = "\eN{e_ACUTE}";
247.Ve
248.Sh "Alias file"
249.IX Subsection "Alias file"
250.Vb 1
251\& use charnames ":full", ":alias" => "pro";
252.Ve
253.PP
254.Vb 2
255\& will try to read "unicore/pro_alias.pl" from the @INC path. This
256\& file should return a list in plain perl:
257.Ve
258.PP
259.Vb 9
260\& (
261\& A_GRAVE => "LATIN CAPITAL LETTER A WITH GRAVE",
262\& A_CIRCUM => "LATIN CAPITAL LETTER A WITH CIRCUMFLEX",
263\& A_DIAERES => "LATIN CAPITAL LETTER A WITH DIAERESIS",
264\& A_TILDE => "LATIN CAPITAL LETTER A WITH TILDE",
265\& A_BREVE => "LATIN CAPITAL LETTER A WITH BREVE",
266\& A_RING => "LATIN CAPITAL LETTER A WITH RING ABOVE",
267\& A_MACRON => "LATIN CAPITAL LETTER A WITH MACRON",
268\& );
269.Ve
270.Sh "Alias shortcut"
271.IX Subsection "Alias shortcut"
272.Vb 1
273\& use charnames ":alias" => ":pro";
274.Ve
275.PP
276.Vb 3
277\& works exactly the same as the alias pairs, only this time,
278\& ":full" is inserted automatically as first argument (if no
279\& other argument is given).
280.Ve
281.SH "charnames::viacode(code)"
282.IX Header "charnames::viacode(code)"
283Returns the full name of the character indicated by the numeric code.
284The example
285.PP
286.Vb 1
287\& print charnames::viacode(0x2722);
288.Ve
289.PP
290prints \*(L"\s-1FOUR\s0 TEARDROP-SPOKED \s-1ASTERISK\s0\*(R".
291.PP
292Returns undef if no name is known for the code.
293.PP
294This works only for the standard names, and does not yet apply
295to custom translators.
296.PP
297Notice that the name returned for of U+FEFF is \*(L"\s-1ZERO\s0 \s-1WIDTH\s0 NO-BREAK
298\&\s-1SPACE\s0\*(R", not \*(L"\s-1BYTE\s0 \s-1ORDER\s0 \s-1MARK\s0\*(R".
299.SH "charnames::vianame(name)"
300.IX Header "charnames::vianame(name)"
301Returns the code point indicated by the name.
302The example
303.PP
304.Vb 1
305\& printf "%04X", charnames::vianame("FOUR TEARDROP-SPOKED ASTERISK");
306.Ve
307.PP
308prints \*(L"2722\*(R".
309.PP
310Returns undef if the name is unknown.
311.PP
312This works only for the standard names, and does not yet apply
313to custom translators.
314.SH "ALIASES"
315.IX Header "ALIASES"
316A few aliases have been defined for convenience: instead of having
317to use the official names
318.PP
319.Vb 4
320\& LINE FEED (LF)
321\& FORM FEED (FF)
322\& CARRIAGE RETURN (CR)
323\& NEXT LINE (NEL)
324.Ve
325.PP
326(yes, with parentheses) one can use
327.PP
328.Vb 8
329\& LINE FEED
330\& FORM FEED
331\& CARRIAGE RETURN
332\& NEXT LINE
333\& LF
334\& FF
335\& CR
336\& NEL
337.Ve
338.PP
339One can also use
340.PP
341.Vb 2
342\& BYTE ORDER MARK
343\& BOM
344.Ve
345.PP
346and
347.PP
348.Vb 2
349\& ZWNJ
350\& ZWJ
351.Ve
352.PP
353for \s-1ZERO\s0 \s-1WIDTH\s0 NON-JOINER and \s-1ZERO\s0 \s-1WIDTH\s0 \s-1JOINER\s0.
354.PP
355For backward compatibility one can use the old names for
356certain C0 and C1 controls
357.PP
358.Vb 1
359\& old new
360.Ve
361.PP
362.Vb 8
363\& HORIZONTAL TABULATION CHARACTER TABULATION
364\& VERTICAL TABULATION LINE TABULATION
365\& FILE SEPARATOR INFORMATION SEPARATOR FOUR
366\& GROUP SEPARATOR INFORMATION SEPARATOR THREE
367\& RECORD SEPARATOR INFORMATION SEPARATOR TWO
368\& UNIT SEPARATOR INFORMATION SEPARATOR ONE
369\& PARTIAL LINE DOWN PARTIAL LINE FORWARD
370\& PARTIAL LINE UP PARTIAL LINE BACKWARD
371.Ve
372.PP
373but the old names in addition to giving the character
374will also give a warning about being deprecated.
375.SH "ILLEGAL CHARACTERS"
376.IX Header "ILLEGAL CHARACTERS"
377If you ask by name for a character that does not exist, a warning is
378given and the Unicode \fIreplacement character\fR \*(L"\ex{\s-1FFFD\s0}\*(R" is returned.
379.PP
380If you ask by code for a character that does not exist, no warning is
381given and \f(CW\*(C`undef\*(C'\fR is returned. (Though if you ask for a code point
382past U+10FFFF you do get a warning.)
383.SH "BUGS"
384.IX Header "BUGS"
385Since evaluation of the translation function happens in a middle of
386compilation (of a string literal), the translation function should not
387do any \f(CW\*(C`eval\*(C'\fRs or \f(CW\*(C`require\*(C'\fRs. This restriction should be lifted in
388a future version of Perl.