1 .\" $OpenBSD: vis.3,v 1.3 1996/08/19 08:27:34 tholo 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. All advertising materials mentioning features or use of this software
15 .\" must display the following acknowledgement:
16 .\" This product includes software developed by the University of
17 .\" California, Berkeley and its contributors.
18 .\" 4. Neither the name of the University nor the names of its contributors
19 .\" may be used to endorse or promote products derived from this software
20 .\" without specific prior written permission.
22 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 .Os "Linux NetKit (0.17)"
39 .Nd visually encode characters
43 .Fn vis "char *dst" "char c" "int flag" "char nextc"
45 .Fn strvis "char *dst" "char *src" "int flag"
47 .Fn strvisx "char *dst" "char *src" "int len" "int flag"
54 a string which represents the character
58 needs no encoding, it is copied in unaltered. The string is
59 null terminated, and a pointer to the end of the string is
60 returned. The maximum length of any encoding is four
61 characters (not including the trailing
64 encoding a set of characters into a buffer, the size of the buffer should
65 be four times the number of characters encoded, plus one for the trailing
67 The flag parameter is used for altering the default range of
68 characters considered for encoding and for altering the visual
70 The additional character,
72 is only used when selecting the
74 encoding format (explained below).
82 a visual representation of
87 function encodes characters from
94 function encodes exactly
99 is useful for encoding a block of data that may contain
107 must be four times the number
108 of characters encoded from
113 forms return the number of characters in dst (not including
117 The encoding is a unique, invertible representation composed entirely of
118 graphic characters; it can be decoded back into the original form using
125 There are two parameters that can be controlled: the range of
126 characters that are encoded, and the type
127 of representation used.
128 By default, all non-graphic characters.
129 except space, tab, and newline are encoded.
134 .Bl -tag -width VIS_WHITEX
149 Only encode "unsafe" characters. Unsafe means control
150 characters which may cause common terminals to perform
151 unexpected functions. Currently this form allows space,
152 tab, newline, backspace, bell, and return - in addition
153 to all graphic characters - unencoded.
156 There are three forms of encoding.
157 All forms use the backslash character
159 to introduce a special
160 sequence; two backslashes are used to represent a real backslash.
161 These are the visual formats:
162 .Bl -tag -width VIS_CSTYLE
166 to represent meta characters (characters with the 8th
167 bit set), and use caret
169 to represent control characters see
170 .Pf ( Xr iscntrl 3 ) .
171 The following formats are used:
172 .Bl -tag -width xxxxx
174 Represents the control character
187 with the 8th bit set.
193 Represents control character
195 with the 8th bit set.
209 Represents Meta-space.
213 Use C-style backslash sequences to represent standard non-printable
215 The following sequences are used to represent the indicated characters:
216 .Bd -unfilled -offset indent
217 .Li \ea Tn - BEL No (007)
218 .Li \eb Tn - BS No (010)
219 .Li \ef Tn - NP No (014)
220 .Li \en Tn - NL No (012)
221 .Li \er Tn - CR No (015)
222 .Li \et Tn - HT No (011)
223 .Li \ev Tn - VT No (013)
224 .Li \e0 Tn - NUL No (000)
227 When using this format, the nextc parameter is looked at to determine
230 character can be encoded as
236 is an octal digit, the latter representation is used to
239 Use a three digit octal sequence. The form is
243 represents an octal digit.
246 There is one additional flag,
249 doubling of backslashes and the backslash before the default
250 format (that is, control characters are represented by
255 With this flag set, the encoding is
256 ambiguous and non-invertible.
262 These functions first appeared in 4.4BSD.