1 .\" $NetBSD: vis.3,v 1.22 2006/04/09 15:24:34 jschauma Exp $
3 .\" Copyright (c) 1989, 1991, 1993
4 .\" The Regents of the University of California. All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
14 .\" 3. Neither the name of the University nor the names of its contributors
15 .\" may be used to endorse or promote products derived from this software
16 .\" without specific prior written permission.
18 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" @(#)vis.3 8.1 (Berkeley) 6/9/93
42 .Nd visually encode characters
48 .Fn vis "char *dst" "int c" "int flag" "int nextc"
50 .Fn strvis "char *dst" "const char *src" "int flag"
52 .Fn strvisx "char *dst" "const char *src" "size_t len" "int flag"
54 .Fn svis "char *dst" "int c" "int flag" "int nextc" "const char *extra"
56 .Fn strsvis "char *dst" "const char *src" "int flag" "const char *extra"
58 .Fn strsvisx "char *dst" "const char *src" "size_t len" "int flag" "const char *extra"
65 a string which represents the character
69 needs no encoding, it is copied in unaltered.
70 The string is null terminated, and a pointer to the end of the string is
72 The maximum length of any encoding is four
73 characters (not including the trailing
76 encoding a set of characters into a buffer, the size of the buffer should
77 be four times the number of characters encoded, plus one for the trailing
79 The flag parameter is used for altering the default range of
80 characters considered for encoding and for altering the visual
82 The additional character,
84 is only used when selecting the
86 encoding format (explained below).
94 a visual representation of
99 function encodes characters from
106 function encodes exactly
111 is useful for encoding a block of data that may contain
119 must be four times the number
120 of characters encoded from
125 forms return the number of characters in dst (not including
139 but have an additional argument
143 terminated list of characters.
144 These characters will be copied encoded or backslash-escaped into
146 These functions are useful e.g. to remove the special meaning
147 of certain characters to shells.
149 The encoding is a unique, invertible representation composed entirely of
150 graphic characters; it can be decoded back into the original form using
157 There are two parameters that can be controlled: the range of
158 characters that are encoded (applies only to
163 and the type of representation used.
164 By default, all non-graphic characters,
165 except space, tab, and newline are encoded.
170 .Bl -tag -width VIS_WHITEX
185 Only encode "unsafe" characters.
186 Unsafe means control characters which may cause common terminals to perform
187 unexpected functions.
188 Currently this form allows space, tab, newline, backspace, bell, and
189 return - in addition to all graphic characters - unencoded.
192 (The above flags have no effect for
197 When using these functions, place all graphic characters to be
198 encoded in an array pointed to by
200 In general, the backslash character should be included in this array, see the
201 warning on the use of the
205 There are four forms of encoding.
206 All forms use the backslash character
208 to introduce a special
209 sequence; two backslashes are used to represent a real backslash,
218 These are the visual formats:
219 .Bl -tag -width VIS_CSTYLE
223 to represent meta characters (characters with the 8th
224 bit set), and use caret
226 to represent control characters see
227 .Pf ( Xr iscntrl 3 ) .
228 The following formats are used:
229 .Bl -tag -width xxxxx
231 Represents the control character
244 with the 8th bit set.
250 Represents control character
252 with the 8th bit set.
266 Represents Meta-space.
270 Use C-style backslash sequences to represent standard non-printable
272 The following sequences are used to represent the indicated characters:
273 .Bd -unfilled -offset indent
274 .Li \ea Tn - BEL No (007)
275 .Li \eb Tn - BS No (010)
276 .Li \ef Tn - NP No (014)
277 .Li \en Tn - NL No (012)
278 .Li \er Tn - CR No (015)
279 .Li \es Tn - SP No (040)
280 .Li \et Tn - HT No (011)
281 .Li \ev Tn - VT No (013)
282 .Li \e0 Tn - NUL No (000)
285 When using this format, the nextc parameter is looked at to determine
288 character can be encoded as
294 is an octal digit, the latter representation is used to
297 Use a three digit octal sequence.
302 represents an octal digit.
304 Use URI encoding as described in RFC 1738.
309 represents a lower case hexadecimal digit.
311 Use MIME Quoted-Printable encoding as described in RFC 2045, only don't
312 break lines and don't handle CRLF.
317 represents an upper case hexadecimal digit.
320 There is one additional flag,
323 doubling of backslashes and the backslash before the default
324 format (that is, control characters are represented by
329 With this flag set, the encoding is
330 ambiguous and non-invertible.
337 .%T Uniform Resource Locators (URL)
346 functions first appeared in
353 functions appeared in