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 .\" 4. Neither the name of the University nor the names of its contributors
13 .\" may be used to endorse or promote products derived from this software
14 .\" without specific prior written permission.
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 .\" From: @(#)vis.3 8.1 (Berkeley) 6/9/93
29 .\" $FreeBSD: src/lib/libc/gen/vis.3,v 1.30 2007/01/09 00:27:56 imp Exp $
36 .Nd visually encode characters
42 .Fn vis "char *dst" "int c" "int flag" "int nextc"
44 .Fn strvis "char *dst" "const char *src" "int flag"
46 .Fn strvisx "char *dst" "const char *src" "size_t len" "int flag"
53 a string which represents the character
57 needs no encoding, it is copied in unaltered.
59 null terminated, and a pointer to the end of the string is
61 The maximum length of any encoding is four
62 characters (not including the trailing
65 encoding a set of characters into a buffer, the size of the buffer should
66 be four times the number of characters encoded, plus one for the trailing
70 argument is used for altering the default range of
71 characters considered for encoding and for altering the visual
73 The additional character,
75 is only used when selecting the
77 encoding format (explained below).
85 a visual representation of
90 function encodes characters from
97 function encodes exactly
102 is useful for encoding a block of data that may contain
110 must be four times the number
111 of characters encoded from
116 forms return the number of characters in dst (not including
120 The encoding is a unique, invertible representation composed entirely of
121 graphic characters; it can be decoded back into the original form using
128 There are two parameters that can be controlled: the range of
129 characters that are encoded, and the type
130 of representation used.
131 By default, all non-graphic characters
132 except space, tab, and newline are encoded.
137 .Bl -tag -width VIS_WHITEX
139 Also encode magic characters
161 Only encode "unsafe" characters.
163 characters which may cause common terminals to perform
164 unexpected functions.
165 Currently this form allows space,
166 tab, newline, backspace, bell, and return - in addition
167 to all graphic characters - unencoded.
170 There are four forms of encoding.
171 Most forms use the backslash character
173 to introduce a special
174 sequence; two backslashes are used to represent a real backslash.
175 These are the visual formats:
176 .Bl -tag -width VIS_HTTPSTYLE
180 to represent meta characters (characters with the 8th
181 bit set), and use caret
183 to represent control characters see
184 .Pf ( Xr iscntrl 3 ) .
185 The following formats are used:
186 .Bl -tag -width xxxxx
188 Represents the control character
201 with the 8th bit set.
207 Represents control character
209 with the 8th bit set.
223 Represents Meta-space.
227 Use C-style backslash sequences to represent standard non-printable
229 The following sequences are used to represent the indicated characters:
231 .Bl -tag -width ".Li \e0" -offset indent -compact
252 When using this format, the
254 argument is looked at to determine
257 character can be encoded as
263 is an octal digit, the latter representation is used to
266 Use URI encoding as described in RFC 1808.
271 represents a hexadecimal digit.
273 Use a three digit octal sequence.
278 represents an octal digit.
281 There is one additional flag,
284 doubling of backslashes and the backslash before the default
285 format (that is, control characters are represented by
290 With this flag set, the encoding is
291 ambiguous and non-invertible.
297 .%T Relative Uniform Resource Locators
301 These functions first appeared in
306 family of functions do not recognize multibyte characters, and thus
307 may consider them to be non-printable when they are in fact printable