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 $
30 .\" $DragonFly: src/lib/libc/gen/vis.3,v 1.5 2007/11/23 23:16:36 swildner Exp $
37 .Nd visually encode characters
43 .Fn vis "char *dst" "int c" "int flag" "int nextc"
45 .Fn strvis "char *dst" "const char *src" "int flag"
47 .Fn strnvis "char *dst" "const char *src" "size_t len" "int flag"
49 .Fn strvisx "char *dst" "const char *src" "size_t len" "int flag"
56 a string which represents the character
60 needs no encoding, it is copied in unaltered.
62 null terminated, and a pointer to the end of the string is
64 The maximum length of any encoding is four
65 characters (not including the trailing
68 encoding a set of characters into a buffer, the size of the buffer should
69 be four times the number of characters encoded, plus one for the trailing
73 argument is used for altering the default range of
74 characters considered for encoding and for altering the visual
76 The additional character,
78 is only used when selecting the
80 encoding format (explained below).
89 a visual representation of
94 function encodes characters from
107 and terminates the string with
111 function encodes exactly
116 is useful for encoding a block of data that may contain
124 must be four times the number
125 of characters encoded from
130 forms return the number of characters in dst (not including
134 The encoding is a unique, invertible representation composed entirely of
135 graphic characters; it can be decoded back into the original form using
142 There are two parameters that can be controlled: the range of
143 characters that are encoded, and the type
144 of representation used.
145 By default, all non-graphic characters
146 except space, tab, and newline are encoded.
151 .Bl -tag -width VIS_WHITEX
153 Also encode magic characters
175 Only encode "unsafe" characters.
177 characters which may cause common terminals to perform
178 unexpected functions.
179 Currently this form allows space,
180 tab, newline, backspace, bell, and return - in addition
181 to all graphic characters - unencoded.
184 There are four forms of encoding.
185 Most forms use the backslash character
187 to introduce a special
188 sequence; two backslashes are used to represent a real backslash.
189 These are the visual formats:
190 .Bl -tag -width VIS_HTTPSTYLE
194 to represent meta characters (characters with the 8th
195 bit set), and use caret
197 to represent control characters see
198 .Pf ( Xr iscntrl 3 ) .
199 The following formats are used:
200 .Bl -tag -width xxxxx
202 Represents the control character
215 with the 8th bit set.
221 Represents control character
223 with the 8th bit set.
237 Represents Meta-space.
241 Use C-style backslash sequences to represent standard non-printable
243 The following sequences are used to represent the indicated characters:
245 .Bl -tag -width ".Li \e0" -offset indent -compact
264 When using this format, the
266 argument is looked at to determine
269 character can be encoded as
275 is an octal digit, the latter representation is used to
278 Use URI encoding as described in RFC 1808.
283 represents a hexadecimal digit.
285 Use a three digit octal sequence.
290 represents an octal digit.
293 There is one additional flag,
296 doubling of backslashes and the backslash before the default
297 format (that is, control characters are represented by
302 With this flag set, the encoding is
303 ambiguous and non-invertible.
309 .%T Relative Uniform Resource Locators
313 These functions first appeared in
318 family of functions do not recognize multibyte characters, and thus
319 may consider them to be non-printable when they are in fact printable