summaryrefslogtreecommitdiffstats
path: root/doc/groff.html.node/Character-Classes.html
blob: 6e315dde9502286af02b1a8c9a09c21a0d4116b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<!DOCTYPE html>
<html>
<!-- Created by GNU Texinfo 7.0.3, https://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- This manual documents GNU troff version 1.23.0.

Copyright � 1994-2023 Free Software Foundation, Inc.

Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
copy of the license is included in the section entitled "GNU Free
Documentation License". -->
<title>Character Classes (The GNU Troff Manual)</title>

<meta name="description" content="Character Classes (The GNU Troff Manual)">
<meta name="keywords" content="Character Classes (The GNU Troff Manual)">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta name="viewport" content="width=device-width,initial-scale=1">

<link href="index.html" rel="start" title="Top">
<link href="Request-Index.html" rel="index" title="Request Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Using-Fonts.html" rel="up" title="Using Fonts">
<link href="Special-Fonts.html" rel="next" title="Special Fonts">
<link href="Using-Symbols.html" rel="prev" title="Using Symbols">
<style type="text/css">
<!--
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
div.example {margin-left: 3.2em}
span.r {font-family: initial; font-weight: normal; font-style: normal}
span:hover a.copiable-link {visibility: visible}
strong.def-name {font-family: monospace; font-weight: bold; font-size: larger}
-->
</style>


</head>

<body lang="en">
<div class="subsection-level-extent" id="Character-Classes">
<div class="nav-panel">
<p>
Next: <a href="Special-Fonts.html" accesskey="n" rel="next">Special Fonts</a>, Previous: <a href="Using-Symbols.html" accesskey="p" rel="prev">Using Symbols</a>, Up: <a href="Using-Fonts.html" accesskey="u" rel="up">Using Fonts</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Request-Index.html" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<h4 class="subsection" id="Character-Classes-1">5.19.5 Character Classes</h4>
<a class="index-entry-id" id="index-character-classes"></a>
<a class="index-entry-id" id="index-classes_002c-character"></a>

<p>Classes are particularly useful for East Asian languages such as
Chinese, Japanese, and Korean, where the number of needed characters is
much larger than in European languages, and where large sets of
characters share the same properties.
</p>
<dl class="first-deffn">
<dt class="deffn" id="index-_002eclass"><span class="category-def">Request: </span><span><strong class="def-name"><code class="t">.class</code></strong> <var class="def-var-arguments">name c1 c2 &hellip;</var><a class="copiable-link" href='#index-_002eclass'> &para;</a></span></dt>
<dd><a class="index-entry-id" id="index-class"></a>
<a class="index-entry-id" id="index-character-class-_0028class_0029"></a>
<a class="index-entry-id" id="index-defining-character-class-_0028class_0029"></a>
<a class="index-entry-id" id="index-class-of-characters-_0028class_0029"></a>
<p>Define a character class (or simply &ldquo;class&rdquo;) <var class="var">name</var> comprising
the characters <var class="var">c1</var>, <var class="var">c2</var>, and so on.
</p>
<p>A class thus defined can then be referred to in lieu of listing all the
characters within it.  Currently, only the <code class="code">cflags</code> request can
handle references to character classes.
</p>
<p>In the request&rsquo;s simplest form, each <var class="var">cn</var> is a character (or special
character).
</p>
<div class="example">
<div class="group"><pre class="example-preformatted">.class [quotes] ' \[aq] \[dq] \[oq] \[cq] \[lq] \[rq]
</pre></div></div>

<p>Since class and glyph names share the same name space, it is recommended
to start and end the class name with <code class="code">[</code> and <code class="code">]</code>,
respectively, to avoid collisions with existing character names defined
by GNU <code class="code">troff</code> or the user (with <code class="code">char</code> and related requests).
This practice applies the presence of <code class="code">]</code> in the class name to
prevent the use of the special character escape form
<code class="code">\[<span class="r">&hellip;</span>]</code>, thus you must use the <code class="code">\C</code> escape to access
a class with such a name.
</p>
<a class="index-entry-id" id="index-GGL-_0028groff-glyph-list_0029-1"></a>
<a class="index-entry-id" id="index-groff-glyph-list-_0028GGL_0029-1"></a>
<p>You can also use a character range notation consisting of a
start character followed by &lsquo;<samp class="samp">-</samp>&rsquo; and then an end character.
Internally, GNU <code class="code">troff</code> converts these two symbol names to
Unicode code points (according to the <code class="code">groff</code> glyph list [GGL]),
which then give the start and end value of the range.  If that fails,
the class definition is skipped.
</p>
<p>Furthermore, classes can be nested.
</p>
<div class="example">
<div class="group"><pre class="example-preformatted">.class [prepunct] , : ; &gt; }
.class [prepunctx] \C'[prepunct]' \[u2013]-\[u2016]
</pre></div></div>

<p>The class &lsquo;<samp class="samp">[prepunctx]</samp>&rsquo; thus contains the contents of the class
<code class="code">[prepunct]</code> as defined above (the set &lsquo;<samp class="samp">, : ; &gt; }</samp>&rsquo;), and
characters in the range between <code class="code">U+2013</code> and <code class="code">U+2016</code>.
</p>
<p>If you want to include &lsquo;<samp class="samp">-</samp>&rsquo; in a class, it must be the first
character value in the argument list, otherwise it gets misinterpreted
as part of the range syntax.
</p>
<p>It is not possible to use class names as end points of range
definitions.
</p>
<p>A typical use of the <code class="code">class</code> request is to control line-breaking
and hyphenation rules as defined by the <code class="code">cflags</code> request.  For
example, to inhibit line breaks before the characters belonging to the
<code class="code">prepunctx</code> class defined in the previous example, you can write
the following.
</p>
<div class="example">
<div class="group"><pre class="example-preformatted">.cflags 2 \C'[prepunctx]'
</pre></div></div>

<p>See the <code class="code">cflags</code> request in <a class="ref" href="Using-Symbols.html">Using Symbols</a>, for more details.
</p></dd></dl>


</div>
<hr>
<div class="nav-panel">
<p>
Next: <a href="Special-Fonts.html">Special Fonts</a>, Previous: <a href="Using-Symbols.html">Using Symbols</a>, Up: <a href="Using-Fonts.html">Using Fonts</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Request-Index.html" title="Index" rel="index">Index</a>]</p>
</div>



</body>
</html>