xref: /freebsd/contrib/libc-vis/vis.3 (revision 778c12a6242b1ef82917b9c78386bb4e1bc0e7e1)
1*778c12a6SBrooks Davis.\"	$NetBSD: vis.3,v 1.39 2013/02/20 20:05:26 christos 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*778c12a6SBrooks Davis.Dd February 19, 2013
348ccca122SBrooks Davis.Dt VIS 3
358ccca122SBrooks Davis.Os
368ccca122SBrooks Davis.Sh NAME
378ccca122SBrooks Davis.Nm vis ,
388ccca122SBrooks Davis.Nm nvis ,
398ccca122SBrooks Davis.Nm strvis ,
408ccca122SBrooks Davis.Nm strnvis ,
418ccca122SBrooks Davis.Nm strvisx ,
428ccca122SBrooks Davis.Nm strnvisx ,
43*778c12a6SBrooks Davis.Nm strenvisx ,
448ccca122SBrooks Davis.Nm svis ,
458ccca122SBrooks Davis.Nm snvis ,
468ccca122SBrooks Davis.Nm strsvis ,
478ccca122SBrooks Davis.Nm strsnvis ,
48*778c12a6SBrooks Davis.Nm strsvisx ,
49*778c12a6SBrooks Davis.Nm strsnvisx ,
50*778c12a6SBrooks 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
638ccca122SBrooks Davis.Fn strnvis "char *dst" "size_t dlen" "const char *src" "int flag"
648ccca122SBrooks Davis.Ft int
658ccca122SBrooks Davis.Fn strvisx "char *dst" "const char *src" "size_t len" "int flag"
668ccca122SBrooks Davis.Ft int
678ccca122SBrooks Davis.Fn strnvisx "char *dst" "size_t dlen" "const char *src" "size_t len" "int flag"
68*778c12a6SBrooks Davis.Ft int
69*778c12a6SBrooks Davis.Fn strenvisx "char *dst" "size_t dlen" "const char *src" "size_t len" "int flag" "int *cerr_ptr"
708ccca122SBrooks Davis.Ft char *
718ccca122SBrooks Davis.Fn svis "char *dst" "int c" "int flag" "int nextc" "const char *extra"
728ccca122SBrooks Davis.Ft char *
738ccca122SBrooks Davis.Fn snvis "char *dst" "size_t dlen" "int c" "int flag" "int nextc" "const char *extra"
748ccca122SBrooks Davis.Ft int
758ccca122SBrooks Davis.Fn strsvis "char *dst" "const char *src" "int flag" "const char *extra"
768ccca122SBrooks Davis.Ft int
778ccca122SBrooks Davis.Fn strsnvis "char *dst" "size_t dlen" "const char *src" "int flag" "const char *extra"
788ccca122SBrooks Davis.Ft int
798ccca122SBrooks Davis.Fn strsvisx "char *dst" "const char *src" "size_t len" "int flag" "const char *extra"
808ccca122SBrooks Davis.Ft int
818ccca122SBrooks Davis.Fn strsnvisx "char *dst" "size_t dlen" "const char *src" "size_t len" "int flag" "const char *extra"
82*778c12a6SBrooks Davis.Ft int
83*778c12a6SBrooks Davis.Fn strsenvisx "char *dst" "size_t dlen" "const char *src" "size_t len" "int flag" "const char *extra" "int *cerr_ptr"
848ccca122SBrooks Davis.Sh DESCRIPTION
858ccca122SBrooks DavisThe
868ccca122SBrooks Davis.Fn vis
878ccca122SBrooks Davisfunction
888ccca122SBrooks Daviscopies into
898ccca122SBrooks Davis.Fa dst
908ccca122SBrooks Davisa string which represents the character
918ccca122SBrooks Davis.Fa c .
928ccca122SBrooks DavisIf
938ccca122SBrooks Davis.Fa c
948ccca122SBrooks Davisneeds no encoding, it is copied in unaltered.
958ccca122SBrooks DavisThe string is null terminated, and a pointer to the end of the string is
968ccca122SBrooks Davisreturned.
978ccca122SBrooks DavisThe maximum length of any encoding is four
98*778c12a6SBrooks Davisbytes (not including the trailing
998ccca122SBrooks Davis.Dv NUL ) ;
1008ccca122SBrooks Davisthus, when
1018ccca122SBrooks Davisencoding a set of characters into a buffer, the size of the buffer should
102*778c12a6SBrooks Davisbe four times the number of bytes encoded, plus one for the trailing
1038ccca122SBrooks Davis.Dv NUL .
1048ccca122SBrooks DavisThe flag parameter is used for altering the default range of
1058ccca122SBrooks Davischaracters considered for encoding and for altering the visual
1068ccca122SBrooks Davisrepresentation.
1078ccca122SBrooks DavisThe additional character,
1088ccca122SBrooks Davis.Fa nextc ,
1098ccca122SBrooks Davisis only used when selecting the
1108ccca122SBrooks Davis.Dv VIS_CSTYLE
1118ccca122SBrooks Davisencoding format (explained below).
1128ccca122SBrooks Davis.Pp
1138ccca122SBrooks DavisThe
1148ccca122SBrooks Davis.Fn strvis ,
1158ccca122SBrooks Davis.Fn strnvis ,
1168ccca122SBrooks Davis.Fn strvisx ,
1178ccca122SBrooks Davisand
1188ccca122SBrooks Davis.Fn strnvisx
1198ccca122SBrooks Davisfunctions copy into
1208ccca122SBrooks Davis.Fa dst
1218ccca122SBrooks Davisa visual representation of
1228ccca122SBrooks Davisthe string
1238ccca122SBrooks Davis.Fa src .
1248ccca122SBrooks DavisThe
1258ccca122SBrooks Davis.Fn strvis
1268ccca122SBrooks Davisand
1278ccca122SBrooks Davis.Fn strnvis
1288ccca122SBrooks Davisfunctions encode characters from
1298ccca122SBrooks Davis.Fa src
1308ccca122SBrooks Davisup to the
1318ccca122SBrooks Davisfirst
1328ccca122SBrooks Davis.Dv NUL .
1338ccca122SBrooks DavisThe
1348ccca122SBrooks Davis.Fn strvisx
1358ccca122SBrooks Davisand
1368ccca122SBrooks Davis.Fn strnvisx
1378ccca122SBrooks Davisfunctions encode exactly
1388ccca122SBrooks Davis.Fa len
1398ccca122SBrooks Davischaracters from
1408ccca122SBrooks Davis.Fa src
1418ccca122SBrooks Davis(this
1428ccca122SBrooks Davisis useful for encoding a block of data that may contain
1438ccca122SBrooks Davis.Dv NUL Ns 's ) .
1448ccca122SBrooks DavisBoth forms
1458ccca122SBrooks Davis.Dv NUL
1468ccca122SBrooks Davisterminate
1478ccca122SBrooks Davis.Fa dst .
1488ccca122SBrooks DavisThe size of
1498ccca122SBrooks Davis.Fa dst
1508ccca122SBrooks Davismust be four times the number
151*778c12a6SBrooks Davisof bytes encoded from
1528ccca122SBrooks Davis.Fa src
1538ccca122SBrooks Davis(plus one for the
1548ccca122SBrooks Davis.Dv NUL ) .
1558ccca122SBrooks DavisBoth
156*778c12a6SBrooks Davisforms return the number of characters in
157*778c12a6SBrooks Davis.Fa dst
158*778c12a6SBrooks Davis(not including the trailing
1598ccca122SBrooks Davis.Dv NUL ) .
1608ccca122SBrooks DavisThe
161*778c12a6SBrooks Davis.Dq Nm n
1628ccca122SBrooks Davisversions of the functions also take an additional argument
1638ccca122SBrooks Davis.Fa dlen
1648ccca122SBrooks Davisthat indicates the length of the
1658ccca122SBrooks Davis.Fa dst
1668ccca122SBrooks Davisbuffer.
1678ccca122SBrooks DavisIf
1688ccca122SBrooks Davis.Fa dlen
169*778c12a6SBrooks Davisis not large enough to fit the converted string then the
1708ccca122SBrooks Davis.Fn strnvis
1718ccca122SBrooks Davisand
1728ccca122SBrooks Davis.Fn strnvisx
1738ccca122SBrooks Davisfunctions return \-1 and set
1748ccca122SBrooks Davis.Va errno
1758ccca122SBrooks Davisto
1768ccca122SBrooks Davis.Dv ENOSPC .
177*778c12a6SBrooks DavisThe
178*778c12a6SBrooks Davis.Fn strenvisx
179*778c12a6SBrooks Davisfunction takes an additional argument,
180*778c12a6SBrooks Davis.Fa cerr_ptr ,
181*778c12a6SBrooks Davisthat is used to pass in and out a multibyte conversion error flag.
182*778c12a6SBrooks DavisThis is useful when processing single characters at a time when
183*778c12a6SBrooks Davisit is possible that the locale may be set to something other
184*778c12a6SBrooks Davisthan the locale of the characters in the input data.
1858ccca122SBrooks Davis.Pp
1868ccca122SBrooks DavisThe functions
1878ccca122SBrooks Davis.Fn svis ,
1888ccca122SBrooks Davis.Fn snvis ,
1898ccca122SBrooks Davis.Fn strsvis ,
1908ccca122SBrooks Davis.Fn strsnvis ,
1918ccca122SBrooks Davis.Fn strsvisx ,
192*778c12a6SBrooks Davis.Fn strsnvisx ,
1938ccca122SBrooks Davisand
194*778c12a6SBrooks Davis.Fn strsenvisx
1958ccca122SBrooks Daviscorrespond to
1968ccca122SBrooks Davis.Fn vis ,
1978ccca122SBrooks Davis.Fn nvis ,
1988ccca122SBrooks Davis.Fn strvis ,
1998ccca122SBrooks Davis.Fn strnvis ,
2008ccca122SBrooks Davis.Fn strvisx ,
201*778c12a6SBrooks Davis.Fn strnvisx ,
2028ccca122SBrooks Davisand
203*778c12a6SBrooks Davis.Fn strenvisx
2048ccca122SBrooks Davisbut have an additional argument
2058ccca122SBrooks Davis.Fa extra ,
2068ccca122SBrooks Davispointing to a
2078ccca122SBrooks Davis.Dv NUL
2088ccca122SBrooks Davisterminated list of characters.
2098ccca122SBrooks DavisThese characters will be copied encoded or backslash-escaped into
2108ccca122SBrooks Davis.Fa dst .
2118ccca122SBrooks DavisThese functions are useful e.g. to remove the special meaning
2128ccca122SBrooks Davisof certain characters to shells.
2138ccca122SBrooks Davis.Pp
2148ccca122SBrooks DavisThe encoding is a unique, invertible representation composed entirely of
2158ccca122SBrooks Davisgraphic characters; it can be decoded back into the original form using
2168ccca122SBrooks Davisthe
2178ccca122SBrooks Davis.Xr unvis 3 ,
2188ccca122SBrooks Davis.Xr strunvis 3
2198ccca122SBrooks Davisor
2208ccca122SBrooks Davis.Xr strnunvis 3
2218ccca122SBrooks Davisfunctions.
2228ccca122SBrooks Davis.Pp
2238ccca122SBrooks DavisThere are two parameters that can be controlled: the range of
2248ccca122SBrooks Davischaracters that are encoded (applies only to
2258ccca122SBrooks Davis.Fn vis ,
2268ccca122SBrooks Davis.Fn nvis ,
2278ccca122SBrooks Davis.Fn strvis ,
2288ccca122SBrooks Davis.Fn strnvis ,
2298ccca122SBrooks Davis.Fn strvisx ,
2308ccca122SBrooks Davisand
2318ccca122SBrooks Davis.Fn strnvisx ) ,
2328ccca122SBrooks Davisand the type of representation used.
2338ccca122SBrooks DavisBy default, all non-graphic characters,
234*778c12a6SBrooks Davisexcept space, tab, and newline are encoded (see
235*778c12a6SBrooks Davis.Xr isgraph 3 ) .
2368ccca122SBrooks DavisThe following flags
2378ccca122SBrooks Davisalter this:
2388ccca122SBrooks Davis.Bl -tag -width VIS_WHITEX
2398ccca122SBrooks Davis.It Dv VIS_GLOB
240*778c12a6SBrooks DavisAlso encode the magic characters
2418ccca122SBrooks Davis.Ql ( * ,
2428ccca122SBrooks Davis.Ql \&? ,
2438ccca122SBrooks Davis.Ql \&[
2448ccca122SBrooks Davisand
2458ccca122SBrooks Davis.Ql # )
2468ccca122SBrooks Davisrecognized by
2478ccca122SBrooks Davis.Xr glob 3 .
2488ccca122SBrooks Davis.It Dv VIS_SP
2498ccca122SBrooks DavisAlso encode space.
2508ccca122SBrooks Davis.It Dv VIS_TAB
2518ccca122SBrooks DavisAlso encode tab.
2528ccca122SBrooks Davis.It Dv VIS_NL
2538ccca122SBrooks DavisAlso encode newline.
2548ccca122SBrooks Davis.It Dv VIS_WHITE
2558ccca122SBrooks DavisSynonym for
2568ccca122SBrooks Davis.Dv VIS_SP
2578ccca122SBrooks Davis\&|
2588ccca122SBrooks Davis.Dv VIS_TAB
2598ccca122SBrooks Davis\&|
2608ccca122SBrooks Davis.Dv VIS_NL .
2618ccca122SBrooks Davis.It Dv VIS_SAFE
262*778c12a6SBrooks DavisOnly encode
263*778c12a6SBrooks Davis.Dq unsafe
264*778c12a6SBrooks Davischaracters.
2658ccca122SBrooks DavisUnsafe means control characters which may cause common terminals to perform
2668ccca122SBrooks Davisunexpected functions.
2678ccca122SBrooks DavisCurrently this form allows space, tab, newline, backspace, bell, and
268*778c12a6SBrooks Davisreturn \(em in addition to all graphic characters \(em unencoded.
2698ccca122SBrooks Davis.El
2708ccca122SBrooks Davis.Pp
2718ccca122SBrooks Davis(The above flags have no effect for
2728ccca122SBrooks Davis.Fn svis ,
2738ccca122SBrooks Davis.Fn snvis ,
2748ccca122SBrooks Davis.Fn strsvis ,
2758ccca122SBrooks Davis.Fn strsnvis ,
2768ccca122SBrooks Davis.Fn strsvisx ,
2778ccca122SBrooks Davisand
2788ccca122SBrooks Davis.Fn strsnvisx .
2798ccca122SBrooks DavisWhen using these functions, place all graphic characters to be
2808ccca122SBrooks Davisencoded in an array pointed to by
2818ccca122SBrooks Davis.Fa extra .
2828ccca122SBrooks DavisIn general, the backslash character should be included in this array, see the
2838ccca122SBrooks Daviswarning on the use of the
2848ccca122SBrooks Davis.Dv VIS_NOSLASH
2858ccca122SBrooks Davisflag below).
2868ccca122SBrooks Davis.Pp
2878ccca122SBrooks DavisThere are four forms of encoding.
2888ccca122SBrooks DavisAll forms use the backslash character
2898ccca122SBrooks Davis.Ql \e
2908ccca122SBrooks Davisto introduce a special
2918ccca122SBrooks Davissequence; two backslashes are used to represent a real backslash,
2928ccca122SBrooks Davisexcept
2938ccca122SBrooks Davis.Dv VIS_HTTPSTYLE
2948ccca122SBrooks Davisthat uses
2958ccca122SBrooks Davis.Ql % ,
2968ccca122SBrooks Davisor
2978ccca122SBrooks Davis.Dv VIS_MIMESTYLE
2988ccca122SBrooks Davisthat uses
2998ccca122SBrooks Davis.Ql = .
3008ccca122SBrooks DavisThese are the visual formats:
3018ccca122SBrooks Davis.Bl -tag -width VIS_CSTYLE
3028ccca122SBrooks Davis.It (default)
3038ccca122SBrooks DavisUse an
3048ccca122SBrooks Davis.Ql M
3058ccca122SBrooks Davisto represent meta characters (characters with the 8th
3068ccca122SBrooks Davisbit set), and use caret
3078ccca122SBrooks Davis.Ql ^
308*778c12a6SBrooks Davisto represent control characters (see
309*778c12a6SBrooks Davis.Xr iscntrl 3 ) .
3108ccca122SBrooks DavisThe following formats are used:
3118ccca122SBrooks Davis.Bl -tag -width xxxxx
3128ccca122SBrooks Davis.It Dv \e^C
3138ccca122SBrooks DavisRepresents the control character
3148ccca122SBrooks Davis.Ql C .
3158ccca122SBrooks DavisSpans characters
3168ccca122SBrooks Davis.Ql \e000
3178ccca122SBrooks Davisthrough
3188ccca122SBrooks Davis.Ql \e037 ,
3198ccca122SBrooks Davisand
3208ccca122SBrooks Davis.Ql \e177
3218ccca122SBrooks Davis(as
3228ccca122SBrooks Davis.Ql \e^? ) .
3238ccca122SBrooks Davis.It Dv \eM-C
3248ccca122SBrooks DavisRepresents character
3258ccca122SBrooks Davis.Ql C
3268ccca122SBrooks Daviswith the 8th bit set.
3278ccca122SBrooks DavisSpans characters
3288ccca122SBrooks Davis.Ql \e241
3298ccca122SBrooks Davisthrough
3308ccca122SBrooks Davis.Ql \e376 .
3318ccca122SBrooks Davis.It Dv \eM^C
3328ccca122SBrooks DavisRepresents control character
3338ccca122SBrooks Davis.Ql C
3348ccca122SBrooks Daviswith the 8th bit set.
3358ccca122SBrooks DavisSpans characters
3368ccca122SBrooks Davis.Ql \e200
3378ccca122SBrooks Davisthrough
3388ccca122SBrooks Davis.Ql \e237 ,
3398ccca122SBrooks Davisand
3408ccca122SBrooks Davis.Ql \e377
3418ccca122SBrooks Davis(as
3428ccca122SBrooks Davis.Ql \eM^? ) .
3438ccca122SBrooks Davis.It Dv \e040
3448ccca122SBrooks DavisRepresents
3458ccca122SBrooks Davis.Tn ASCII
3468ccca122SBrooks Davisspace.
3478ccca122SBrooks Davis.It Dv \e240
3488ccca122SBrooks DavisRepresents Meta-space.
3498ccca122SBrooks Davis.El
3508ccca122SBrooks Davis.Pp
3518ccca122SBrooks Davis.It Dv VIS_CSTYLE
3528ccca122SBrooks DavisUse C-style backslash sequences to represent standard non-printable
3538ccca122SBrooks Davischaracters.
3548ccca122SBrooks DavisThe following sequences are used to represent the indicated characters:
3558ccca122SBrooks Davis.Bd -unfilled -offset indent
356*778c12a6SBrooks Davis.Li \ea Tn  \(em BEL No (007)
357*778c12a6SBrooks Davis.Li \eb Tn  \(em BS No (010)
358*778c12a6SBrooks Davis.Li \ef Tn  \(em NP No (014)
359*778c12a6SBrooks Davis.Li \en Tn  \(em NL No (012)
360*778c12a6SBrooks Davis.Li \er Tn  \(em CR No (015)
361*778c12a6SBrooks Davis.Li \es Tn  \(em SP No (040)
362*778c12a6SBrooks Davis.Li \et Tn  \(em HT No (011)
363*778c12a6SBrooks Davis.Li \ev Tn  \(em VT No (013)
364*778c12a6SBrooks Davis.Li \e0 Tn  \(em NUL No (000)
3658ccca122SBrooks Davis.Ed
3668ccca122SBrooks Davis.Pp
367*778c12a6SBrooks DavisWhen using this format, the
368*778c12a6SBrooks Davis.Fa nextc
369*778c12a6SBrooks Davisparameter is looked at to determine if a
3708ccca122SBrooks Davis.Dv NUL
3718ccca122SBrooks Davischaracter can be encoded as
3728ccca122SBrooks Davis.Ql \e0
3738ccca122SBrooks Davisinstead of
3748ccca122SBrooks Davis.Ql \e000 .
3758ccca122SBrooks DavisIf
3768ccca122SBrooks Davis.Fa nextc
3778ccca122SBrooks Davisis an octal digit, the latter representation is used to
3788ccca122SBrooks Davisavoid ambiguity.
3798ccca122SBrooks Davis.It Dv VIS_OCTAL
3808ccca122SBrooks DavisUse a three digit octal sequence.
3818ccca122SBrooks DavisThe form is
3828ccca122SBrooks Davis.Ql \eddd
3838ccca122SBrooks Daviswhere
3848ccca122SBrooks Davis.Em d
3858ccca122SBrooks Davisrepresents an octal digit.
3868ccca122SBrooks Davis.It Dv VIS_HTTPSTYLE
3878ccca122SBrooks DavisUse URI encoding as described in RFC 1738.
3888ccca122SBrooks DavisThe form is
3898ccca122SBrooks Davis.Ql %xx
3908ccca122SBrooks Daviswhere
3918ccca122SBrooks Davis.Em x
3928ccca122SBrooks Davisrepresents a lower case hexadecimal digit.
3938ccca122SBrooks Davis.It Dv VIS_MIMESTYLE
3948ccca122SBrooks DavisUse MIME Quoted-Printable encoding as described in RFC 2045, only don't
3958ccca122SBrooks Davisbreak lines and don't handle CRLF.
396*778c12a6SBrooks DavisThe form is
397*778c12a6SBrooks Davis.Ql =XX
3988ccca122SBrooks Daviswhere
3998ccca122SBrooks Davis.Em X
4008ccca122SBrooks Davisrepresents an upper case hexadecimal digit.
4018ccca122SBrooks Davis.El
4028ccca122SBrooks Davis.Pp
4038ccca122SBrooks DavisThere is one additional flag,
4048ccca122SBrooks Davis.Dv VIS_NOSLASH ,
4058ccca122SBrooks Daviswhich inhibits the
4068ccca122SBrooks Davisdoubling of backslashes and the backslash before the default
4078ccca122SBrooks Davisformat (that is, control characters are represented by
4088ccca122SBrooks Davis.Ql ^C
4098ccca122SBrooks Davisand
4108ccca122SBrooks Davismeta characters as
4118ccca122SBrooks Davis.Ql M-C ) .
4128ccca122SBrooks DavisWith this flag set, the encoding is
4138ccca122SBrooks Davisambiguous and non-invertible.
414*778c12a6SBrooks Davis.Sh MULTIBYTE CHARACTER SUPPORT
415*778c12a6SBrooks DavisThese functions support multibyte character input.
416*778c12a6SBrooks DavisThe encoding conversion is influenced by the setting of the
417*778c12a6SBrooks Davis.Ev LC_CTYPE
418*778c12a6SBrooks Davisenvironment variable which defines the set of characters
419*778c12a6SBrooks Davisthat can be copied without encoding.
420*778c12a6SBrooks Davis.Pp
421*778c12a6SBrooks DavisWhen 8-bit data is present in the input,
422*778c12a6SBrooks Davis.Ev LC_CTYPE
423*778c12a6SBrooks Davismust be set to the correct locale or to the C locale.
424*778c12a6SBrooks DavisIf the locales of the data and the conversion are mismatched,
425*778c12a6SBrooks Davismultibyte character recognition may fail and encoding will be performed
426*778c12a6SBrooks Davisbyte-by-byte instead.
427*778c12a6SBrooks Davis.Pp
428*778c12a6SBrooks DavisAs noted above,
429*778c12a6SBrooks Davis.Fa dst
430*778c12a6SBrooks Davismust be four times the number of bytes processed from
431*778c12a6SBrooks Davis.Fa src .
432*778c12a6SBrooks DavisBut note that each multibyte character can be up to
433*778c12a6SBrooks Davis.Dv MB_LEN_MAX
434*778c12a6SBrooks Davisbytes
435*778c12a6SBrooks Davis.\" (see
436*778c12a6SBrooks Davis.\" .Xr multibyte 3 )
437*778c12a6SBrooks Davisso in terms of multibyte characters,
438*778c12a6SBrooks Davis.Fa dst
439*778c12a6SBrooks Davismust be four times
440*778c12a6SBrooks Davis.Dv MB_LEN_MAX
441*778c12a6SBrooks Davistimes the number of characters processed from
442*778c12a6SBrooks Davis.Fa src .
443*778c12a6SBrooks Davis.Sh ENVIRONMENT
444*778c12a6SBrooks Davis.Bl -tag -width ".Ev LC_CTYPE"
445*778c12a6SBrooks Davis.It Ev LC_CTYPE
446*778c12a6SBrooks DavisSpecify the locale of the input data.
447*778c12a6SBrooks DavisSet to C if the input data locale is unknown.
448*778c12a6SBrooks Davis.El
4498ccca122SBrooks Davis.Sh ERRORS
4508ccca122SBrooks DavisThe functions
4518ccca122SBrooks Davis.Fn nvis
4528ccca122SBrooks Davisand
4538ccca122SBrooks Davis.Fn snvis
4548ccca122SBrooks Daviswill return
4558ccca122SBrooks Davis.Dv NULL
4568ccca122SBrooks Davisand the functions
4578ccca122SBrooks Davis.Fn strnvis ,
4588ccca122SBrooks Davis.Fn strnvisx ,
4598ccca122SBrooks Davis.Fn strsnvis ,
4608ccca122SBrooks Davisand
4618ccca122SBrooks Davis.Fn strsnvisx ,
4628ccca122SBrooks Daviswill return \-1 when the
4638ccca122SBrooks Davis.Fa dlen
464*778c12a6SBrooks Davisdestination buffer size is not enough to perform the conversion while
4658ccca122SBrooks Davissetting
4668ccca122SBrooks Davis.Va errno
4678ccca122SBrooks Davisto:
468*778c12a6SBrooks Davis.Bl -tag -width ".Bq Er ENOSPC"
4698ccca122SBrooks Davis.It Bq Er ENOSPC
4708ccca122SBrooks DavisThe destination buffer size is not large enough to perform the conversion.
4718ccca122SBrooks Davis.El
4728ccca122SBrooks Davis.Sh SEE ALSO
4738ccca122SBrooks Davis.Xr unvis 1 ,
4748ccca122SBrooks Davis.Xr vis 1 ,
4758ccca122SBrooks Davis.Xr glob 3 ,
476*778c12a6SBrooks Davis.\" .Xr multibyte 3 ,
4778ccca122SBrooks Davis.Xr unvis 3
4788ccca122SBrooks Davis.Rs
4798ccca122SBrooks Davis.%A T. Berners-Lee
4808ccca122SBrooks Davis.%T Uniform Resource Locators (URL)
481*778c12a6SBrooks Davis.%O "RFC 1738"
482*778c12a6SBrooks Davis.Re
483*778c12a6SBrooks Davis.Rs
484*778c12a6SBrooks Davis.%T "Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies"
485*778c12a6SBrooks Davis.%O "RFC 2045"
4868ccca122SBrooks Davis.Re
4878ccca122SBrooks Davis.Sh HISTORY
4888ccca122SBrooks DavisThe
4898ccca122SBrooks Davis.Fn vis ,
4908ccca122SBrooks Davis.Fn strvis ,
4918ccca122SBrooks Davisand
492*778c12a6SBrooks Davis.Fn strvisx
4938ccca122SBrooks Davisfunctions first appeared in
4948ccca122SBrooks Davis.Bx 4.4 .
4958ccca122SBrooks DavisThe
4968ccca122SBrooks Davis.Fn svis ,
4978ccca122SBrooks Davis.Fn strsvis ,
4988ccca122SBrooks Davisand
4998ccca122SBrooks Davis.Fn strsvisx
5008ccca122SBrooks Davisfunctions appeared in
5018ccca122SBrooks Davis.Nx 1.5
5028ccca122SBrooks Davisand
503*778c12a6SBrooks Davis.Fx 9.2 .
5048ccca122SBrooks DavisThe buffer size limited versions of the functions
5058ccca122SBrooks Davis.Po Fn nvis ,
5068ccca122SBrooks Davis.Fn strnvis ,
5078ccca122SBrooks Davis.Fn strnvisx ,
5088ccca122SBrooks Davis.Fn snvis ,
5098ccca122SBrooks Davis.Fn strsnvis ,
5108ccca122SBrooks Davisand
5118ccca122SBrooks Davis.Fn strsnvisx Pc
5128ccca122SBrooks Davisappeared in
5138ccca122SBrooks Davisand
514*778c12a6SBrooks Davis.Fx 9.2 .
515*778c12a6SBrooks DavisMyltibyte character support was added in
516*778c12a6SBrooks Davis.Nx 7.0
517*778c12a6SBrooks Davisand
518*778c12a6SBrooks Davis.Fx 9.2 .
519