.\" Copyright (c) 1989, 1991 The Regents of the University of California.
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" @(#)vis.3 5.7 (Berkeley) 4/19/91
.Nd visually encode characters
.Fn vis "char *dst" "char c" "int flag" "char nextc"
.Fn strvis "char *dst" "char *src" "int flag"
.Fn strvisx "char *dst" "char *src" "int len" "int flag"
a string which represents the character
needs no encoding, it is copied in unaltered. The string is
null terminated, and a pointer to the end of the string is
returned. The maximum length of any encoding is four
characters (not including the trailing
encoding a set of characters into a buffer, the size of the buffer should
be four times the number of characters encoded, plus one for the trailing
The flag parameter is used for altering the default range of
characters considered for encoding and for altering the visual
The additional character,
is only used when selecting the
encoding format (explained below).
a visual representation of
function encodes characters from
is useful for encoding a block of data that may contain
must be four times the number
of characters encoded from
forms return the number of characters in dst (not including
The encoding is a unique, invertible representation comprised entirely of
graphic characters; it can be decoded back into the original form using
There are two parameters that can be controlled: the range of
characters that are encoded, and the type
By default, all non-graphic characters.
except space, tab, and newline are encoded.
.Bl -tag -width VIS_WHITEX
Only encode "unsafe" characters. Unsafe means control
characters which may cause common terminals to perform
unexpected functions. Currently this form allows space,
tab, newline, backspace, bell, and return - in addition
to all graphic characters - unencoded.
There are three forms of encoding.
All forms use the backslash character
sequence; two backslashes are used to represent a real backslash.
These are the visual formats:
.Bl -tag -width VIS_CSTYLE
to represent meta characters (characters with the 8th
to represent control characters see
The following formats are used:
Represents the control character
Represents control character
Use C-style backslash sequences to represent standard non-printable
The following sequences are used to represent the indicated characters:
.Bd -unfilled -offset indent
.Li \ea Tn - BEL No (007)
.Li \e0 Tn - NUL No (000)
When using this format, the nextc parameter is looked at to determine
character can be encoded as
is an octal digit, the latter representation is used to
Use a three digit octal sequence. The form is
represents an octal digit.
There is one additional flag,
doubling of backslashes and the backslash before the default
format (that is, control characters are represented by
With this flag set, the encoding is
ambiguous and non-invertible.