1 .\" Copyright (c) 1989, 1991, 1993
2 .\" The Regents of the University of California. All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" 3. All advertising materials mentioning features or use of this software
13 .\" must display the following acknowledgement:
14 .\" This product includes software developed by the University of
15 .\" California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\" may be used to endorse or promote products derived from this software
18 .\" without specific prior written permission.
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .\" From: @(#)vis.3 8.1 (Berkeley) 6/9/93
33 .\" $FreeBSD: src/lib/libc/gen/vis.3,v 1.20 2002/12/19 09:40:21 ru Exp $
40 .Nd visually encode characters
46 .Fn vis "char *dst" "int c" "int flag" "int nextc"
48 .Fn strvis "char *dst" "const char *src" "int flag"
50 .Fn strvisx "char *dst" "const char *src" "size_t len" "int flag"
57 a string which represents the character
61 needs no encoding, it is copied in unaltered. The string is
62 null terminated, and a pointer to the end of the string is
63 returned. The maximum length of any encoding is four
64 characters (not including the trailing
67 encoding a set of characters into a buffer, the size of the buffer should
68 be four times the number of characters encoded, plus one for the trailing
72 argument is used for altering the default range of
73 characters considered for encoding and for altering the visual
75 The additional character,
77 is only used when selecting the
79 encoding format (explained below).
87 a visual representation of
92 function encodes characters from
99 function encodes exactly
104 is useful for encoding a block of data that may contain
112 must be four times the number
113 of characters encoded from
118 forms return the number of characters in dst (not including
122 The encoding is a unique, invertible representation composed entirely of
123 graphic characters; it can be decoded back into the original form using
130 There are two parameters that can be controlled: the range of
131 characters that are encoded, and the type
132 of representation used.
133 By default, all non-graphic characters
134 except space, tab, and newline are encoded.
139 .Bl -tag -width VIS_WHITEX
154 Only encode "unsafe" characters. Unsafe means control
155 characters which may cause common terminals to perform
156 unexpected functions. Currently this form allows space,
157 tab, newline, backspace, bell, and return - in addition
158 to all graphic characters - unencoded.
161 There are four forms of encoding.
162 Most forms use the backslash character
164 to introduce a special
165 sequence; two backslashes are used to represent a real backslash.
166 These are the visual formats:
167 .Bl -tag -width VIS_HTTPSTYLE
171 to represent meta characters (characters with the 8th
172 bit set), and use carat
174 to represent control characters see
175 .Pf ( Xr iscntrl 3 ) .
176 The following formats are used:
177 .Bl -tag -width xxxxx
179 Represents the control character
192 with the 8th bit set.
198 Represents control character
200 with the 8th bit set.
214 Represents Meta-space.
218 Use C-style backslash sequences to represent standard non-printable
220 The following sequences are used to represent the indicated characters:
221 .Bd -unfilled -offset indent
222 .Li \ea Tn - BEL No (007)
223 .Li \eb Tn - BS No (010)
224 .Li \ef Tn - NP No (014)
225 .Li \en Tn - NL No (012)
226 .Li \er Tn - CR No (015)
227 .Li \et Tn - HT No (011)
228 .Li \ev Tn - VT No (013)
229 .Li \e0 Tn - NUL No (000)
232 When using this format, the
234 argument is looked at to determine
237 character can be encoded as
243 is an octal digit, the latter representation is used to
246 Use URI encoding as described in RFC 1808.
251 represents a hexadecimal digit.
253 Use a three digit octal sequence. The form is
257 represents an octal digit.
260 There is one additional flag,
263 doubling of backslashes and the backslash before the default
264 format (that is, control characters are represented by
269 With this flag set, the encoding is
270 ambiguous and non-invertible.
276 .%T Relative Uniform Resource Locators
280 These functions first appeared in