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.27 2005/01/15 11:40:33 ru Exp $
34 .\" $DragonFly: src/lib/libc/gen/vis.3,v 1.5 2007/11/23 23:16:36 swildner Exp $
41 .Nd visually encode characters
47 .Fn vis "char *dst" "int c" "int flag" "int nextc"
49 .Fn strvis "char *dst" "const char *src" "int flag"
51 .Fn strnvis "char *dst" "const char *src" "size_t len" "int flag"
53 .Fn strvisx "char *dst" "const char *src" "size_t len" "int flag"
60 a string which represents the character
64 needs no encoding, it is copied in unaltered.
66 null terminated, and a pointer to the end of the string is
68 The maximum length of any encoding is four
69 characters (not including the trailing
72 encoding a set of characters into a buffer, the size of the buffer should
73 be four times the number of characters encoded, plus one for the trailing
77 argument is used for altering the default range of
78 characters considered for encoding and for altering the visual
80 The additional character,
82 is only used when selecting the
84 encoding format (explained below).
93 a visual representation of
98 function encodes characters from
111 and terminates the string with
115 function encodes exactly
120 is useful for encoding a block of data that may contain
128 must be four times the number
129 of characters encoded from
134 forms return the number of characters in dst (not including
138 The encoding is a unique, invertible representation composed entirely of
139 graphic characters; it can be decoded back into the original form using
146 There are two parameters that can be controlled: the range of
147 characters that are encoded, and the type
148 of representation used.
149 By default, all non-graphic characters
150 except space, tab, and newline are encoded.
155 .Bl -tag -width VIS_WHITEX
157 Also encode magic characters
179 Only encode "unsafe" characters.
181 characters which may cause common terminals to perform
182 unexpected functions.
183 Currently this form allows space,
184 tab, newline, backspace, bell, and return - in addition
185 to all graphic characters - unencoded.
188 There are four forms of encoding.
189 Most forms use the backslash character
191 to introduce a special
192 sequence; two backslashes are used to represent a real backslash.
193 These are the visual formats:
194 .Bl -tag -width VIS_HTTPSTYLE
198 to represent meta characters (characters with the 8th
199 bit set), and use caret
201 to represent control characters see
202 .Pf ( Xr iscntrl 3 ) .
203 The following formats are used:
204 .Bl -tag -width xxxxx
206 Represents the control character
219 with the 8th bit set.
225 Represents control character
227 with the 8th bit set.
241 Represents Meta-space.
245 Use C-style backslash sequences to represent standard non-printable
247 The following sequences are used to represent the indicated characters:
249 .Bl -tag -width ".Li \e0" -offset indent -compact
268 When using this format, the
270 argument is looked at to determine
273 character can be encoded as
279 is an octal digit, the latter representation is used to
282 Use URI encoding as described in RFC 1808.
287 represents a hexadecimal digit.
289 Use a three digit octal sequence.
294 represents an octal digit.
297 There is one additional flag,
300 doubling of backslashes and the backslash before the default
301 format (that is, control characters are represented by
306 With this flag set, the encoding is
307 ambiguous and non-invertible.
313 .%T Relative Uniform Resource Locators
317 These functions first appeared in
322 family of functions do not recognize multibyte characters, and thus
323 may consider them to be non-printable when they are in fact printable