.\" Copyright (c) 1989, 1991 The Regents of the University of California.
.\" %sccs.include.redist.man%
.\" @(#)vis.3 5.7 (Berkeley) %G%
.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.