xref: /freebsd/contrib/libc-vis/vis.3 (revision ff88ef4183d34943e90dda4138857bcee2d8e092)
1*ff88ef41SBrooks Davis.\"	$NetBSD: vis.3,v 1.49 2017/08/05 20:22:29 wiz Exp $
28ccca122SBrooks Davis.\"	$FreeBSD$
38ccca122SBrooks Davis.\"
48ccca122SBrooks Davis.\" Copyright (c) 1989, 1991, 1993
58ccca122SBrooks Davis.\"	The Regents of the University of California.  All rights reserved.
68ccca122SBrooks Davis.\"
78ccca122SBrooks Davis.\" Redistribution and use in source and binary forms, with or without
88ccca122SBrooks Davis.\" modification, are permitted provided that the following conditions
98ccca122SBrooks Davis.\" are met:
108ccca122SBrooks Davis.\" 1. Redistributions of source code must retain the above copyright
118ccca122SBrooks Davis.\"    notice, this list of conditions and the following disclaimer.
128ccca122SBrooks Davis.\" 2. Redistributions in binary form must reproduce the above copyright
138ccca122SBrooks Davis.\"    notice, this list of conditions and the following disclaimer in the
148ccca122SBrooks Davis.\"    documentation and/or other materials provided with the distribution.
158ccca122SBrooks Davis.\" 3. Neither the name of the University nor the names of its contributors
168ccca122SBrooks Davis.\"    may be used to endorse or promote products derived from this software
178ccca122SBrooks Davis.\"    without specific prior written permission.
188ccca122SBrooks Davis.\"
198ccca122SBrooks Davis.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
208ccca122SBrooks Davis.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
218ccca122SBrooks Davis.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
228ccca122SBrooks Davis.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
238ccca122SBrooks Davis.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
248ccca122SBrooks Davis.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
258ccca122SBrooks Davis.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
268ccca122SBrooks Davis.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
278ccca122SBrooks Davis.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
288ccca122SBrooks Davis.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
298ccca122SBrooks Davis.\" SUCH DAMAGE.
308ccca122SBrooks Davis.\"
318ccca122SBrooks Davis.\"     @(#)vis.3	8.1 (Berkeley) 6/9/93
328ccca122SBrooks Davis.\"
33*ff88ef41SBrooks Davis.Dd April 22, 2017
348ccca122SBrooks Davis.Dt VIS 3
358ccca122SBrooks Davis.Os
368ccca122SBrooks Davis.Sh NAME
378ccca122SBrooks Davis.Nm vis ,
388ccca122SBrooks Davis.Nm nvis ,
398ccca122SBrooks Davis.Nm strvis ,
408dfeba04SBrooks Davis.Nm stravis ,
418ccca122SBrooks Davis.Nm strnvis ,
428ccca122SBrooks Davis.Nm strvisx ,
438ccca122SBrooks Davis.Nm strnvisx ,
44778c12a6SBrooks Davis.Nm strenvisx ,
458ccca122SBrooks Davis.Nm svis ,
468ccca122SBrooks Davis.Nm snvis ,
478ccca122SBrooks Davis.Nm strsvis ,
488ccca122SBrooks Davis.Nm strsnvis ,
49778c12a6SBrooks Davis.Nm strsvisx ,
50778c12a6SBrooks Davis.Nm strsnvisx ,
51778c12a6SBrooks Davis.Nm strsenvisx
528ccca122SBrooks Davis.Nd visually encode characters
538ccca122SBrooks Davis.Sh LIBRARY
548ccca122SBrooks Davis.Lb libc
558ccca122SBrooks Davis.Sh SYNOPSIS
568ccca122SBrooks Davis.In vis.h
578ccca122SBrooks Davis.Ft char *
588ccca122SBrooks Davis.Fn vis "char *dst" "int c" "int flag" "int nextc"
598ccca122SBrooks Davis.Ft char *
608ccca122SBrooks Davis.Fn nvis "char *dst" "size_t dlen" "int c" "int flag" "int nextc"
618ccca122SBrooks Davis.Ft int
628ccca122SBrooks Davis.Fn strvis "char *dst" "const char *src" "int flag"
638ccca122SBrooks Davis.Ft int
648dfeba04SBrooks Davis.Fn stravis "char **dst" "const char *src" "int flag"
658dfeba04SBrooks Davis.Ft int
668ccca122SBrooks Davis.Fn strnvis "char *dst" "size_t dlen" "const char *src" "int flag"
678ccca122SBrooks Davis.Ft int
688ccca122SBrooks Davis.Fn strvisx "char *dst" "const char *src" "size_t len" "int flag"
698ccca122SBrooks Davis.Ft int
708ccca122SBrooks Davis.Fn strnvisx "char *dst" "size_t dlen" "const char *src" "size_t len" "int flag"
71778c12a6SBrooks Davis.Ft int
72778c12a6SBrooks Davis.Fn strenvisx "char *dst" "size_t dlen" "const char *src" "size_t len" "int flag" "int *cerr_ptr"
738ccca122SBrooks Davis.Ft char *
748ccca122SBrooks Davis.Fn svis "char *dst" "int c" "int flag" "int nextc" "const char *extra"
758ccca122SBrooks Davis.Ft char *
768ccca122SBrooks Davis.Fn snvis "char *dst" "size_t dlen" "int c" "int flag" "int nextc" "const char *extra"
778ccca122SBrooks Davis.Ft int
788ccca122SBrooks Davis.Fn strsvis "char *dst" "const char *src" "int flag" "const char *extra"
798ccca122SBrooks Davis.Ft int
808ccca122SBrooks Davis.Fn strsnvis "char *dst" "size_t dlen" "const char *src" "int flag" "const char *extra"
818ccca122SBrooks Davis.Ft int
828ccca122SBrooks Davis.Fn strsvisx "char *dst" "const char *src" "size_t len" "int flag" "const char *extra"
838ccca122SBrooks Davis.Ft int
848ccca122SBrooks Davis.Fn strsnvisx "char *dst" "size_t dlen" "const char *src" "size_t len" "int flag" "const char *extra"
85778c12a6SBrooks Davis.Ft int
86778c12a6SBrooks Davis.Fn strsenvisx "char *dst" "size_t dlen" "const char *src" "size_t len" "int flag" "const char *extra" "int *cerr_ptr"
878ccca122SBrooks Davis.Sh DESCRIPTION
888ccca122SBrooks DavisThe
898ccca122SBrooks Davis.Fn vis
908ccca122SBrooks Davisfunction
918ccca122SBrooks Daviscopies into
928ccca122SBrooks Davis.Fa dst
938ccca122SBrooks Davisa string which represents the character
948ccca122SBrooks Davis.Fa c .
958ccca122SBrooks DavisIf
968ccca122SBrooks Davis.Fa c
978ccca122SBrooks Davisneeds no encoding, it is copied in unaltered.
988ccca122SBrooks DavisThe string is null terminated, and a pointer to the end of the string is
998ccca122SBrooks Davisreturned.
1008ccca122SBrooks DavisThe maximum length of any encoding is four
101778c12a6SBrooks Davisbytes (not including the trailing
1028ccca122SBrooks Davis.Dv NUL ) ;
1038ccca122SBrooks Davisthus, when
1048ccca122SBrooks Davisencoding a set of characters into a buffer, the size of the buffer should
105778c12a6SBrooks Davisbe four times the number of bytes encoded, plus one for the trailing
1068ccca122SBrooks Davis.Dv NUL .
1078ccca122SBrooks DavisThe flag parameter is used for altering the default range of
1088ccca122SBrooks Davischaracters considered for encoding and for altering the visual
1098ccca122SBrooks Davisrepresentation.
1108ccca122SBrooks DavisThe additional character,
1118ccca122SBrooks Davis.Fa nextc ,
1128ccca122SBrooks Davisis only used when selecting the
1138ccca122SBrooks Davis.Dv VIS_CSTYLE
1148ccca122SBrooks Davisencoding format (explained below).
1158ccca122SBrooks Davis.Pp
1168ccca122SBrooks DavisThe
1178ccca122SBrooks Davis.Fn strvis ,
1188dfeba04SBrooks Davis.Fn stravis ,
1198ccca122SBrooks Davis.Fn strnvis ,
1208ccca122SBrooks Davis.Fn strvisx ,
1218ccca122SBrooks Davisand
1228ccca122SBrooks Davis.Fn strnvisx
1238ccca122SBrooks Davisfunctions copy into
1248ccca122SBrooks Davis.Fa dst
1258ccca122SBrooks Davisa visual representation of
1268ccca122SBrooks Davisthe string
1278ccca122SBrooks Davis.Fa src .
1288ccca122SBrooks DavisThe
1298ccca122SBrooks Davis.Fn strvis
1308ccca122SBrooks Davisand
1318ccca122SBrooks Davis.Fn strnvis
1328ccca122SBrooks Davisfunctions encode characters from
1338ccca122SBrooks Davis.Fa src
1348ccca122SBrooks Davisup to the
1358ccca122SBrooks Davisfirst
1368ccca122SBrooks Davis.Dv NUL .
1378ccca122SBrooks DavisThe
1388ccca122SBrooks Davis.Fn strvisx
1398ccca122SBrooks Davisand
1408ccca122SBrooks Davis.Fn strnvisx
1418ccca122SBrooks Davisfunctions encode exactly
1428ccca122SBrooks Davis.Fa len
1438ccca122SBrooks Davischaracters from
1448ccca122SBrooks Davis.Fa src
1458ccca122SBrooks Davis(this
1468ccca122SBrooks Davisis useful for encoding a block of data that may contain
1478ccca122SBrooks Davis.Dv NUL Ns 's ) .
1488ccca122SBrooks DavisBoth forms
1498ccca122SBrooks Davis.Dv NUL
1508ccca122SBrooks Davisterminate
1518ccca122SBrooks Davis.Fa dst .
1528ccca122SBrooks DavisThe size of
1538ccca122SBrooks Davis.Fa dst
1548ccca122SBrooks Davismust be four times the number
155778c12a6SBrooks Davisof bytes encoded from
1568ccca122SBrooks Davis.Fa src
1578ccca122SBrooks Davis(plus one for the
1588ccca122SBrooks Davis.Dv NUL ) .
1598ccca122SBrooks DavisBoth
160778c12a6SBrooks Davisforms return the number of characters in
161778c12a6SBrooks Davis.Fa dst
162778c12a6SBrooks Davis(not including the trailing
1638ccca122SBrooks Davis.Dv NUL ) .
1648ccca122SBrooks DavisThe
1658dfeba04SBrooks Davis.Fn stravis
1668dfeba04SBrooks Davisfunction allocates space dynamically to hold the string.
1678dfeba04SBrooks DavisThe
168778c12a6SBrooks Davis.Dq Nm n
1698ccca122SBrooks Davisversions of the functions also take an additional argument
1708ccca122SBrooks Davis.Fa dlen
1718ccca122SBrooks Davisthat indicates the length of the
1728ccca122SBrooks Davis.Fa dst
1738ccca122SBrooks Davisbuffer.
1748ccca122SBrooks DavisIf
1758ccca122SBrooks Davis.Fa dlen
176778c12a6SBrooks Davisis not large enough to fit the converted string then the
1778ccca122SBrooks Davis.Fn strnvis
1788ccca122SBrooks Davisand
1798ccca122SBrooks Davis.Fn strnvisx
1808ccca122SBrooks Davisfunctions return \-1 and set
1818ccca122SBrooks Davis.Va errno
1828ccca122SBrooks Davisto
1838ccca122SBrooks Davis.Dv ENOSPC .
184778c12a6SBrooks DavisThe
185778c12a6SBrooks Davis.Fn strenvisx
186778c12a6SBrooks Davisfunction takes an additional argument,
187778c12a6SBrooks Davis.Fa cerr_ptr ,
188778c12a6SBrooks Davisthat is used to pass in and out a multibyte conversion error flag.
189778c12a6SBrooks DavisThis is useful when processing single characters at a time when
190778c12a6SBrooks Davisit is possible that the locale may be set to something other
191778c12a6SBrooks Davisthan the locale of the characters in the input data.
1928ccca122SBrooks Davis.Pp
1938ccca122SBrooks DavisThe functions
1948ccca122SBrooks Davis.Fn svis ,
1958ccca122SBrooks Davis.Fn snvis ,
1968ccca122SBrooks Davis.Fn strsvis ,
1978ccca122SBrooks Davis.Fn strsnvis ,
1988ccca122SBrooks Davis.Fn strsvisx ,
199778c12a6SBrooks Davis.Fn strsnvisx ,
2008ccca122SBrooks Davisand
201778c12a6SBrooks Davis.Fn strsenvisx
2028ccca122SBrooks Daviscorrespond to
2038ccca122SBrooks Davis.Fn vis ,
2048ccca122SBrooks Davis.Fn nvis ,
2058ccca122SBrooks Davis.Fn strvis ,
2068ccca122SBrooks Davis.Fn strnvis ,
2078ccca122SBrooks Davis.Fn strvisx ,
208778c12a6SBrooks Davis.Fn strnvisx ,
2098ccca122SBrooks Davisand
210778c12a6SBrooks Davis.Fn strenvisx
2118ccca122SBrooks Davisbut have an additional argument
2128ccca122SBrooks Davis.Fa extra ,
2138ccca122SBrooks Davispointing to a
2148ccca122SBrooks Davis.Dv NUL
2158ccca122SBrooks Davisterminated list of characters.
2168ccca122SBrooks DavisThese characters will be copied encoded or backslash-escaped into
2178ccca122SBrooks Davis.Fa dst .
2188ccca122SBrooks DavisThese functions are useful e.g. to remove the special meaning
2198ccca122SBrooks Davisof certain characters to shells.
2208ccca122SBrooks Davis.Pp
2218ccca122SBrooks DavisThe encoding is a unique, invertible representation composed entirely of
2228ccca122SBrooks Davisgraphic characters; it can be decoded back into the original form using
2238ccca122SBrooks Davisthe
2248ccca122SBrooks Davis.Xr unvis 3 ,
2258ccca122SBrooks Davis.Xr strunvis 3
2268ccca122SBrooks Davisor
2278ccca122SBrooks Davis.Xr strnunvis 3
2288ccca122SBrooks Davisfunctions.
2298ccca122SBrooks Davis.Pp
2308ccca122SBrooks DavisThere are two parameters that can be controlled: the range of
2318ccca122SBrooks Davischaracters that are encoded (applies only to
2328ccca122SBrooks Davis.Fn vis ,
2338ccca122SBrooks Davis.Fn nvis ,
2348ccca122SBrooks Davis.Fn strvis ,
2358ccca122SBrooks Davis.Fn strnvis ,
2368ccca122SBrooks Davis.Fn strvisx ,
2378ccca122SBrooks Davisand
2388ccca122SBrooks Davis.Fn strnvisx ) ,
2398ccca122SBrooks Davisand the type of representation used.
2408ccca122SBrooks DavisBy default, all non-graphic characters,
241778c12a6SBrooks Davisexcept space, tab, and newline are encoded (see
242778c12a6SBrooks Davis.Xr isgraph 3 ) .
2438ccca122SBrooks DavisThe following flags
2448ccca122SBrooks Davisalter this:
2458ccca122SBrooks Davis.Bl -tag -width VIS_WHITEX
246*ff88ef41SBrooks Davis.It Dv VIS_DQ
247*ff88ef41SBrooks DavisAlso encode double quotes
2488ccca122SBrooks Davis.It Dv VIS_GLOB
249778c12a6SBrooks DavisAlso encode the magic characters
2508ccca122SBrooks Davis.Ql ( * ,
2518ccca122SBrooks Davis.Ql \&? ,
2528dfeba04SBrooks Davis.Ql \&[ ,
2538ccca122SBrooks Davisand
2548ccca122SBrooks Davis.Ql # )
2558ccca122SBrooks Davisrecognized by
2568ccca122SBrooks Davis.Xr glob 3 .
2578dfeba04SBrooks Davis.It Dv VIS_SHELL
2588dfeba04SBrooks DavisAlso encode the meta characters used by shells (in addition to the glob
2598dfeba04SBrooks Davischaracters):
2608dfeba04SBrooks Davis.Ql ( ' ,
2618dfeba04SBrooks Davis.Ql ` ,
2628dfeba04SBrooks Davis.Ql \&" ,
2638dfeba04SBrooks Davis.Ql \&; ,
2648dfeba04SBrooks Davis.Ql & ,
2658dfeba04SBrooks Davis.Ql < ,
2668dfeba04SBrooks Davis.Ql > ,
2678dfeba04SBrooks Davis.Ql \&( ,
2688dfeba04SBrooks Davis.Ql \&) ,
2698dfeba04SBrooks Davis.Ql \&| ,
2708dfeba04SBrooks Davis.Ql \&] ,
2718dfeba04SBrooks Davis.Ql \e ,
2728dfeba04SBrooks Davis.Ql $ ,
2738dfeba04SBrooks Davis.Ql \&! ,
2748dfeba04SBrooks Davis.Ql \&^ ,
2758dfeba04SBrooks Davisand
2768dfeba04SBrooks Davis.Ql ~ ) .
2778ccca122SBrooks Davis.It Dv VIS_SP
2788ccca122SBrooks DavisAlso encode space.
2798ccca122SBrooks Davis.It Dv VIS_TAB
2808ccca122SBrooks DavisAlso encode tab.
2818ccca122SBrooks Davis.It Dv VIS_NL
2828ccca122SBrooks DavisAlso encode newline.
2838ccca122SBrooks Davis.It Dv VIS_WHITE
2848ccca122SBrooks DavisSynonym for
2858dfeba04SBrooks Davis.Dv VIS_SP | VIS_TAB | VIS_NL .
2868dfeba04SBrooks Davis.It Dv VIS_META
2878dfeba04SBrooks DavisSynonym for
2888dfeba04SBrooks Davis.Dv VIS_WHITE | VIS_GLOB | VIS_SHELL .
2898ccca122SBrooks Davis.It Dv VIS_SAFE
290778c12a6SBrooks DavisOnly encode
291778c12a6SBrooks Davis.Dq unsafe
292778c12a6SBrooks Davischaracters.
2938ccca122SBrooks DavisUnsafe means control characters which may cause common terminals to perform
2948ccca122SBrooks Davisunexpected functions.
2958ccca122SBrooks DavisCurrently this form allows space, tab, newline, backspace, bell, and
296778c12a6SBrooks Davisreturn \(em in addition to all graphic characters \(em unencoded.
2978ccca122SBrooks Davis.El
2988ccca122SBrooks Davis.Pp
2998ccca122SBrooks Davis(The above flags have no effect for
3008ccca122SBrooks Davis.Fn svis ,
3018ccca122SBrooks Davis.Fn snvis ,
3028ccca122SBrooks Davis.Fn strsvis ,
3038ccca122SBrooks Davis.Fn strsnvis ,
3048ccca122SBrooks Davis.Fn strsvisx ,
3058ccca122SBrooks Davisand
3068ccca122SBrooks Davis.Fn strsnvisx .
3078ccca122SBrooks DavisWhen using these functions, place all graphic characters to be
3088ccca122SBrooks Davisencoded in an array pointed to by
3098ccca122SBrooks Davis.Fa extra .
3108ccca122SBrooks DavisIn general, the backslash character should be included in this array, see the
3118ccca122SBrooks Daviswarning on the use of the
3128ccca122SBrooks Davis.Dv VIS_NOSLASH
3138ccca122SBrooks Davisflag below).
3148ccca122SBrooks Davis.Pp
315*ff88ef41SBrooks DavisThere are six forms of encoding.
3168ccca122SBrooks DavisAll forms use the backslash character
3178ccca122SBrooks Davis.Ql \e
3188ccca122SBrooks Davisto introduce a special
3198ccca122SBrooks Davissequence; two backslashes are used to represent a real backslash,
3208ccca122SBrooks Davisexcept
3218ccca122SBrooks Davis.Dv VIS_HTTPSTYLE
3228ccca122SBrooks Davisthat uses
3238ccca122SBrooks Davis.Ql % ,
3248ccca122SBrooks Davisor
3258ccca122SBrooks Davis.Dv VIS_MIMESTYLE
3268ccca122SBrooks Davisthat uses
3278ccca122SBrooks Davis.Ql = .
3288ccca122SBrooks DavisThese are the visual formats:
3298ccca122SBrooks Davis.Bl -tag -width VIS_CSTYLE
3308ccca122SBrooks Davis.It (default)
3318ccca122SBrooks DavisUse an
3328ccca122SBrooks Davis.Ql M
3338ccca122SBrooks Davisto represent meta characters (characters with the 8th
3348ccca122SBrooks Davisbit set), and use caret
3358ccca122SBrooks Davis.Ql ^
336778c12a6SBrooks Davisto represent control characters (see
337778c12a6SBrooks Davis.Xr iscntrl 3 ) .
3388ccca122SBrooks DavisThe following formats are used:
3398ccca122SBrooks Davis.Bl -tag -width xxxxx
3408ccca122SBrooks Davis.It Dv \e^C
3418ccca122SBrooks DavisRepresents the control character
3428ccca122SBrooks Davis.Ql C .
3438ccca122SBrooks DavisSpans characters
3448ccca122SBrooks Davis.Ql \e000
3458ccca122SBrooks Davisthrough
3468ccca122SBrooks Davis.Ql \e037 ,
3478ccca122SBrooks Davisand
3488ccca122SBrooks Davis.Ql \e177
3498ccca122SBrooks Davis(as
3508ccca122SBrooks Davis.Ql \e^? ) .
3518ccca122SBrooks Davis.It Dv \eM-C
3528ccca122SBrooks DavisRepresents character
3538ccca122SBrooks Davis.Ql C
3548ccca122SBrooks Daviswith the 8th bit set.
3558ccca122SBrooks DavisSpans characters
3568ccca122SBrooks Davis.Ql \e241
3578ccca122SBrooks Davisthrough
3588ccca122SBrooks Davis.Ql \e376 .
3598ccca122SBrooks Davis.It Dv \eM^C
3608ccca122SBrooks DavisRepresents control character
3618ccca122SBrooks Davis.Ql C
3628ccca122SBrooks Daviswith the 8th bit set.
3638ccca122SBrooks DavisSpans characters
3648ccca122SBrooks Davis.Ql \e200
3658ccca122SBrooks Davisthrough
3668ccca122SBrooks Davis.Ql \e237 ,
3678ccca122SBrooks Davisand
3688ccca122SBrooks Davis.Ql \e377
3698ccca122SBrooks Davis(as
3708ccca122SBrooks Davis.Ql \eM^? ) .
3718ccca122SBrooks Davis.It Dv \e040
3728ccca122SBrooks DavisRepresents
3738ccca122SBrooks Davis.Tn ASCII
3748ccca122SBrooks Davisspace.
3758ccca122SBrooks Davis.It Dv \e240
3768ccca122SBrooks DavisRepresents Meta-space.
3778ccca122SBrooks Davis.El
3788ccca122SBrooks Davis.It Dv VIS_CSTYLE
3798ccca122SBrooks DavisUse C-style backslash sequences to represent standard non-printable
3808ccca122SBrooks Davischaracters.
3818ccca122SBrooks DavisThe following sequences are used to represent the indicated characters:
3828ccca122SBrooks Davis.Bd -unfilled -offset indent
383778c12a6SBrooks Davis.Li \ea Tn  \(em BEL No (007)
384778c12a6SBrooks Davis.Li \eb Tn  \(em BS No (010)
385778c12a6SBrooks Davis.Li \ef Tn  \(em NP No (014)
386778c12a6SBrooks Davis.Li \en Tn  \(em NL No (012)
387778c12a6SBrooks Davis.Li \er Tn  \(em CR No (015)
388778c12a6SBrooks Davis.Li \es Tn  \(em SP No (040)
389778c12a6SBrooks Davis.Li \et Tn  \(em HT No (011)
390778c12a6SBrooks Davis.Li \ev Tn  \(em VT No (013)
391778c12a6SBrooks Davis.Li \e0 Tn  \(em NUL No (000)
3928ccca122SBrooks Davis.Ed
3938ccca122SBrooks Davis.Pp
394778c12a6SBrooks DavisWhen using this format, the
395778c12a6SBrooks Davis.Fa nextc
396778c12a6SBrooks Davisparameter is looked at to determine if a
3978ccca122SBrooks Davis.Dv NUL
3988ccca122SBrooks Davischaracter can be encoded as
3998ccca122SBrooks Davis.Ql \e0
4008ccca122SBrooks Davisinstead of
4018ccca122SBrooks Davis.Ql \e000 .
4028ccca122SBrooks DavisIf
4038ccca122SBrooks Davis.Fa nextc
4048ccca122SBrooks Davisis an octal digit, the latter representation is used to
4058ccca122SBrooks Davisavoid ambiguity.
406*ff88ef41SBrooks Davis.Pp
407*ff88ef41SBrooks DavisNon-printable characters without C-style
408*ff88ef41SBrooks Davisbackslash sequences use the default representation.
4098ccca122SBrooks Davis.It Dv VIS_OCTAL
4108ccca122SBrooks DavisUse a three digit octal sequence.
4118ccca122SBrooks DavisThe form is
4128ccca122SBrooks Davis.Ql \eddd
4138ccca122SBrooks Daviswhere
4148ccca122SBrooks Davis.Em d
4158ccca122SBrooks Davisrepresents an octal digit.
416*ff88ef41SBrooks Davis.It Dv VIS_CSTYLE \&| Dv VIS_OCTAL
417*ff88ef41SBrooks DavisSame as
418*ff88ef41SBrooks Davis.Dv VIS_CSTYLE
419*ff88ef41SBrooks Davisexcept that non-printable characters without C-style
420*ff88ef41SBrooks Davisbackslash sequences use a three digit octal sequence.
4218ccca122SBrooks Davis.It Dv VIS_HTTPSTYLE
4228ccca122SBrooks DavisUse URI encoding as described in RFC 1738.
4238ccca122SBrooks DavisThe form is
4248ccca122SBrooks Davis.Ql %xx
4258ccca122SBrooks Daviswhere
4268ccca122SBrooks Davis.Em x
4278ccca122SBrooks Davisrepresents a lower case hexadecimal digit.
4288ccca122SBrooks Davis.It Dv VIS_MIMESTYLE
4298ccca122SBrooks DavisUse MIME Quoted-Printable encoding as described in RFC 2045, only don't
4308ccca122SBrooks Davisbreak lines and don't handle CRLF.
431778c12a6SBrooks DavisThe form is
432778c12a6SBrooks Davis.Ql =XX
4338ccca122SBrooks Daviswhere
4348ccca122SBrooks Davis.Em X
4358ccca122SBrooks Davisrepresents an upper case hexadecimal digit.
4368ccca122SBrooks Davis.El
4378ccca122SBrooks Davis.Pp
4388ccca122SBrooks DavisThere is one additional flag,
4398ccca122SBrooks Davis.Dv VIS_NOSLASH ,
4408ccca122SBrooks Daviswhich inhibits the
4418ccca122SBrooks Davisdoubling of backslashes and the backslash before the default
4428ccca122SBrooks Davisformat (that is, control characters are represented by
4438ccca122SBrooks Davis.Ql ^C
4448ccca122SBrooks Davisand
4458ccca122SBrooks Davismeta characters as
4468ccca122SBrooks Davis.Ql M-C ) .
4478ccca122SBrooks DavisWith this flag set, the encoding is
4488ccca122SBrooks Davisambiguous and non-invertible.
449778c12a6SBrooks Davis.Sh MULTIBYTE CHARACTER SUPPORT
450778c12a6SBrooks DavisThese functions support multibyte character input.
451778c12a6SBrooks DavisThe encoding conversion is influenced by the setting of the
452778c12a6SBrooks Davis.Ev LC_CTYPE
453778c12a6SBrooks Davisenvironment variable which defines the set of characters
454778c12a6SBrooks Davisthat can be copied without encoding.
455778c12a6SBrooks Davis.Pp
4568dfeba04SBrooks DavisIf
4578dfeba04SBrooks Davis.Dv VIS_NOLOCALE
4588dfeba04SBrooks Davisis set, processing is done assuming the C locale and overriding
4598dfeba04SBrooks Davisany other environment settings.
4608dfeba04SBrooks Davis.Pp
461778c12a6SBrooks DavisWhen 8-bit data is present in the input,
462778c12a6SBrooks Davis.Ev LC_CTYPE
463778c12a6SBrooks Davismust be set to the correct locale or to the C locale.
464778c12a6SBrooks DavisIf the locales of the data and the conversion are mismatched,
465778c12a6SBrooks Davismultibyte character recognition may fail and encoding will be performed
466778c12a6SBrooks Davisbyte-by-byte instead.
467778c12a6SBrooks Davis.Pp
468778c12a6SBrooks DavisAs noted above,
469778c12a6SBrooks Davis.Fa dst
470778c12a6SBrooks Davismust be four times the number of bytes processed from
471778c12a6SBrooks Davis.Fa src .
472778c12a6SBrooks DavisBut note that each multibyte character can be up to
473778c12a6SBrooks Davis.Dv MB_LEN_MAX
474778c12a6SBrooks Davisbytes
475778c12a6SBrooks Davis.\" (see
476778c12a6SBrooks Davis.\" .Xr multibyte 3 )
477778c12a6SBrooks Davisso in terms of multibyte characters,
478778c12a6SBrooks Davis.Fa dst
479778c12a6SBrooks Davismust be four times
480778c12a6SBrooks Davis.Dv MB_LEN_MAX
481778c12a6SBrooks Davistimes the number of characters processed from
482778c12a6SBrooks Davis.Fa src .
483778c12a6SBrooks Davis.Sh ENVIRONMENT
484778c12a6SBrooks Davis.Bl -tag -width ".Ev LC_CTYPE"
485778c12a6SBrooks Davis.It Ev LC_CTYPE
486778c12a6SBrooks DavisSpecify the locale of the input data.
487778c12a6SBrooks DavisSet to C if the input data locale is unknown.
488778c12a6SBrooks Davis.El
4898ccca122SBrooks Davis.Sh ERRORS
4908ccca122SBrooks DavisThe functions
4918ccca122SBrooks Davis.Fn nvis
4928ccca122SBrooks Davisand
4938ccca122SBrooks Davis.Fn snvis
4948ccca122SBrooks Daviswill return
4958ccca122SBrooks Davis.Dv NULL
4968ccca122SBrooks Davisand the functions
4978ccca122SBrooks Davis.Fn strnvis ,
4988ccca122SBrooks Davis.Fn strnvisx ,
4998ccca122SBrooks Davis.Fn strsnvis ,
5008ccca122SBrooks Davisand
5018ccca122SBrooks Davis.Fn strsnvisx ,
5028ccca122SBrooks Daviswill return \-1 when the
5038ccca122SBrooks Davis.Fa dlen
504778c12a6SBrooks Davisdestination buffer size is not enough to perform the conversion while
5058ccca122SBrooks Davissetting
5068ccca122SBrooks Davis.Va errno
5078ccca122SBrooks Davisto:
508778c12a6SBrooks Davis.Bl -tag -width ".Bq Er ENOSPC"
5098ccca122SBrooks Davis.It Bq Er ENOSPC
5108ccca122SBrooks DavisThe destination buffer size is not large enough to perform the conversion.
5118ccca122SBrooks Davis.El
5128ccca122SBrooks Davis.Sh SEE ALSO
5138ccca122SBrooks Davis.Xr unvis 1 ,
5148ccca122SBrooks Davis.Xr vis 1 ,
5158ccca122SBrooks Davis.Xr glob 3 ,
516778c12a6SBrooks Davis.\" .Xr multibyte 3 ,
5178ccca122SBrooks Davis.Xr unvis 3
5188ccca122SBrooks Davis.Rs
5198ccca122SBrooks Davis.%A T. Berners-Lee
5208ccca122SBrooks Davis.%T Uniform Resource Locators (URL)
521778c12a6SBrooks Davis.%O "RFC 1738"
522778c12a6SBrooks Davis.Re
523778c12a6SBrooks Davis.Rs
524778c12a6SBrooks Davis.%T "Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies"
525778c12a6SBrooks Davis.%O "RFC 2045"
5268ccca122SBrooks Davis.Re
5278ccca122SBrooks Davis.Sh HISTORY
5288ccca122SBrooks DavisThe
5298ccca122SBrooks Davis.Fn vis ,
5308ccca122SBrooks Davis.Fn strvis ,
5318ccca122SBrooks Davisand
532778c12a6SBrooks Davis.Fn strvisx
5338ccca122SBrooks Davisfunctions first appeared in
5348ccca122SBrooks Davis.Bx 4.4 .
5358ccca122SBrooks DavisThe
5368ccca122SBrooks Davis.Fn svis ,
5378ccca122SBrooks Davis.Fn strsvis ,
5388ccca122SBrooks Davisand
5398ccca122SBrooks Davis.Fn strsvisx
5408ccca122SBrooks Davisfunctions appeared in
5418ccca122SBrooks Davis.Nx 1.5
5428ccca122SBrooks Davisand
543778c12a6SBrooks Davis.Fx 9.2 .
5448ccca122SBrooks DavisThe buffer size limited versions of the functions
5458ccca122SBrooks Davis.Po Fn nvis ,
5468ccca122SBrooks Davis.Fn strnvis ,
5478ccca122SBrooks Davis.Fn strnvisx ,
5488ccca122SBrooks Davis.Fn snvis ,
5498ccca122SBrooks Davis.Fn strsnvis ,
5508ccca122SBrooks Davisand
5518ccca122SBrooks Davis.Fn strsnvisx Pc
5528ccca122SBrooks Davisappeared in
553492a99a2SSergey Kandaurov.Nx 6.0
5548ccca122SBrooks Davisand
555778c12a6SBrooks Davis.Fx 9.2 .
5568dfeba04SBrooks DavisMultibyte character support was added in
557778c12a6SBrooks Davis.Nx 7.0
558778c12a6SBrooks Davisand
559778c12a6SBrooks Davis.Fx 9.2 .
560