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