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. 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.27 2005/01/15 11:40:33 ru 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 strnvis "char *dst" "const char *src" "size_t len" "int flag"
48 .Fn strvisx "char *dst" "const char *src" "size_t len" "int flag"
55 a string which represents the character
59 needs no encoding, it is copied in unaltered.
61 null terminated, and a pointer to the end of the string is
63 The maximum length of any encoding is four
64 characters (not including the trailing
67 encoding a set of characters into a buffer, the size of the buffer should
68 be four times the number of characters encoded, plus one for the trailing
72 argument is used for altering the default range of
73 characters considered for encoding and for altering the visual
75 The additional character,
77 is only used when selecting the
79 encoding format (explained below).
88 a visual representation of
93 function encodes characters from
106 and terminates the string with
110 function encodes exactly
115 is useful for encoding a block of data that may contain
123 must be four times the number
124 of characters encoded from
129 forms return the number of characters in dst (not including
133 The encoding is a unique, invertible representation composed entirely of
134 graphic characters; it can be decoded back into the original form using
141 There are two parameters that can be controlled: the range of
142 characters that are encoded, and the type
143 of representation used.
144 By default, all non-graphic characters
145 except space, tab, and newline are encoded.
150 .Bl -tag -width ".Dv VIS_HTTPSTYLE"
152 Also encode magic characters
174 Only encode "unsafe" characters.
176 characters which may cause common terminals to perform
177 unexpected functions.
178 Currently this form allows space,
179 tab, newline, backspace, bell, and return - in addition
180 to all graphic characters - unencoded.
183 There are four forms of encoding.
184 Most forms use the backslash character
186 to introduce a special
187 sequence; two backslashes are used to represent a real backslash.
188 These are the visual formats:
189 .Bl -tag -width ".Dv VIS_HTTPSTYLE"
193 to represent meta characters (characters with the 8th
194 bit set), and use caret
196 to represent control characters see
197 .Pf ( Xr iscntrl 3 ) .
198 The following formats are used:
199 .Bl -tag -width xxxxx
201 Represents the control character
214 with the 8th bit set.
220 Represents control character
222 with the 8th bit set.
236 Represents Meta-space.
239 Use C-style backslash sequences to represent standard non-printable
241 The following sequences are used to represent the indicated characters:
243 .Bl -tag -width ".Li \e0" -offset indent -compact
262 When using this format, the
264 argument is looked at to determine
267 character can be encoded as
273 is an octal digit, the latter representation is used to
276 Use URI encoding as described in RFC 1808.
281 represents a hexadecimal digit.
283 Use a three digit octal sequence.
288 represents an octal digit.
291 There is one additional flag,
294 doubling of backslashes and the backslash before the default
295 format (that is, control characters are represented by
300 With this flag set, the encoding is
301 ambiguous and non-invertible.
307 .%T Relative Uniform Resource Locators
311 These functions first appeared in
316 family of functions do not recognize multibyte characters, and thus
317 may consider them to be non-printable when they are in fact printable