1*0a6a1f1dSLionel Sambuc.\" $NetBSD: vis.3,v 1.43 2015/05/23 11:47:56 christos Exp $ 22fe8fb19SBen Gras.\" 32fe8fb19SBen Gras.\" Copyright (c) 1989, 1991, 1993 42fe8fb19SBen Gras.\" The Regents of the University of California. All rights reserved. 52fe8fb19SBen Gras.\" 62fe8fb19SBen Gras.\" Redistribution and use in source and binary forms, with or without 72fe8fb19SBen Gras.\" modification, are permitted provided that the following conditions 82fe8fb19SBen Gras.\" are met: 92fe8fb19SBen Gras.\" 1. Redistributions of source code must retain the above copyright 102fe8fb19SBen Gras.\" notice, this list of conditions and the following disclaimer. 112fe8fb19SBen Gras.\" 2. Redistributions in binary form must reproduce the above copyright 122fe8fb19SBen Gras.\" notice, this list of conditions and the following disclaimer in the 132fe8fb19SBen Gras.\" documentation and/or other materials provided with the distribution. 142fe8fb19SBen Gras.\" 3. Neither the name of the University nor the names of its contributors 152fe8fb19SBen Gras.\" may be used to endorse or promote products derived from this software 162fe8fb19SBen Gras.\" without specific prior written permission. 172fe8fb19SBen Gras.\" 182fe8fb19SBen Gras.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 192fe8fb19SBen Gras.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 202fe8fb19SBen Gras.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 212fe8fb19SBen Gras.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 222fe8fb19SBen Gras.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 232fe8fb19SBen Gras.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 242fe8fb19SBen Gras.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 252fe8fb19SBen Gras.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 262fe8fb19SBen Gras.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 272fe8fb19SBen Gras.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 282fe8fb19SBen Gras.\" SUCH DAMAGE. 292fe8fb19SBen Gras.\" 302fe8fb19SBen Gras.\" @(#)vis.3 8.1 (Berkeley) 6/9/93 312fe8fb19SBen Gras.\" 32*0a6a1f1dSLionel Sambuc.Dd May 23, 2015 332fe8fb19SBen Gras.Dt VIS 3 342fe8fb19SBen Gras.Os 352fe8fb19SBen Gras.Sh NAME 362fe8fb19SBen Gras.Nm vis , 37f14fb602SLionel Sambuc.Nm nvis , 382fe8fb19SBen Gras.Nm strvis , 39f14fb602SLionel Sambuc.Nm strnvis , 402fe8fb19SBen Gras.Nm strvisx , 41f14fb602SLionel Sambuc.Nm strnvisx , 4284d9c625SLionel Sambuc.Nm strenvisx , 432fe8fb19SBen Gras.Nm svis , 44f14fb602SLionel Sambuc.Nm snvis , 452fe8fb19SBen Gras.Nm strsvis , 46f14fb602SLionel Sambuc.Nm strsnvis , 4784d9c625SLionel Sambuc.Nm strsvisx , 4884d9c625SLionel Sambuc.Nm strsnvisx , 4984d9c625SLionel Sambuc.Nm strsenvisx 502fe8fb19SBen Gras.Nd visually encode characters 512fe8fb19SBen Gras.Sh LIBRARY 522fe8fb19SBen Gras.Lb libc 532fe8fb19SBen Gras.Sh SYNOPSIS 542fe8fb19SBen Gras.In vis.h 552fe8fb19SBen Gras.Ft char * 562fe8fb19SBen Gras.Fn vis "char *dst" "int c" "int flag" "int nextc" 57f14fb602SLionel Sambuc.Ft char * 58f14fb602SLionel Sambuc.Fn nvis "char *dst" "size_t dlen" "int c" "int flag" "int nextc" 592fe8fb19SBen Gras.Ft int 602fe8fb19SBen Gras.Fn strvis "char *dst" "const char *src" "int flag" 612fe8fb19SBen Gras.Ft int 62f14fb602SLionel Sambuc.Fn strnvis "char *dst" "size_t dlen" "const char *src" "int flag" 63f14fb602SLionel Sambuc.Ft int 642fe8fb19SBen Gras.Fn strvisx "char *dst" "const char *src" "size_t len" "int flag" 65f14fb602SLionel Sambuc.Ft int 66f14fb602SLionel Sambuc.Fn strnvisx "char *dst" "size_t dlen" "const char *src" "size_t len" "int flag" 6784d9c625SLionel Sambuc.Ft int 6884d9c625SLionel Sambuc.Fn strenvisx "char *dst" "size_t dlen" "const char *src" "size_t len" "int flag" "int *cerr_ptr" 692fe8fb19SBen Gras.Ft char * 702fe8fb19SBen Gras.Fn svis "char *dst" "int c" "int flag" "int nextc" "const char *extra" 71f14fb602SLionel Sambuc.Ft char * 72f14fb602SLionel Sambuc.Fn snvis "char *dst" "size_t dlen" "int c" "int flag" "int nextc" "const char *extra" 732fe8fb19SBen Gras.Ft int 742fe8fb19SBen Gras.Fn strsvis "char *dst" "const char *src" "int flag" "const char *extra" 752fe8fb19SBen Gras.Ft int 76f14fb602SLionel Sambuc.Fn strsnvis "char *dst" "size_t dlen" "const char *src" "int flag" "const char *extra" 77f14fb602SLionel Sambuc.Ft int 782fe8fb19SBen Gras.Fn strsvisx "char *dst" "const char *src" "size_t len" "int flag" "const char *extra" 79f14fb602SLionel Sambuc.Ft int 80f14fb602SLionel Sambuc.Fn strsnvisx "char *dst" "size_t dlen" "const char *src" "size_t len" "int flag" "const char *extra" 8184d9c625SLionel Sambuc.Ft int 8284d9c625SLionel Sambuc.Fn strsenvisx "char *dst" "size_t dlen" "const char *src" "size_t len" "int flag" "const char *extra" "int *cerr_ptr" 832fe8fb19SBen Gras.Sh DESCRIPTION 842fe8fb19SBen GrasThe 852fe8fb19SBen Gras.Fn vis 862fe8fb19SBen Grasfunction 872fe8fb19SBen Grascopies into 882fe8fb19SBen Gras.Fa dst 892fe8fb19SBen Grasa string which represents the character 902fe8fb19SBen Gras.Fa c . 912fe8fb19SBen GrasIf 922fe8fb19SBen Gras.Fa c 932fe8fb19SBen Grasneeds no encoding, it is copied in unaltered. 942fe8fb19SBen GrasThe string is null terminated, and a pointer to the end of the string is 952fe8fb19SBen Grasreturned. 962fe8fb19SBen GrasThe maximum length of any encoding is four 9784d9c625SLionel Sambucbytes (not including the trailing 982fe8fb19SBen Gras.Dv NUL ) ; 992fe8fb19SBen Grasthus, when 1002fe8fb19SBen Grasencoding a set of characters into a buffer, the size of the buffer should 10184d9c625SLionel Sambucbe four times the number of bytes encoded, plus one for the trailing 1022fe8fb19SBen Gras.Dv NUL . 1032fe8fb19SBen GrasThe flag parameter is used for altering the default range of 1042fe8fb19SBen Grascharacters considered for encoding and for altering the visual 1052fe8fb19SBen Grasrepresentation. 1062fe8fb19SBen GrasThe additional character, 1072fe8fb19SBen Gras.Fa nextc , 1082fe8fb19SBen Grasis only used when selecting the 1092fe8fb19SBen Gras.Dv VIS_CSTYLE 1102fe8fb19SBen Grasencoding format (explained below). 1112fe8fb19SBen Gras.Pp 1122fe8fb19SBen GrasThe 113f14fb602SLionel Sambuc.Fn strvis , 114f14fb602SLionel Sambuc.Fn strnvis , 115f14fb602SLionel Sambuc.Fn strvisx , 1162fe8fb19SBen Grasand 117f14fb602SLionel Sambuc.Fn strnvisx 1182fe8fb19SBen Grasfunctions copy into 1192fe8fb19SBen Gras.Fa dst 1202fe8fb19SBen Grasa visual representation of 1212fe8fb19SBen Grasthe string 1222fe8fb19SBen Gras.Fa src . 1232fe8fb19SBen GrasThe 1242fe8fb19SBen Gras.Fn strvis 125f14fb602SLionel Sambucand 126f14fb602SLionel Sambuc.Fn strnvis 127f14fb602SLionel Sambucfunctions encode characters from 1282fe8fb19SBen Gras.Fa src 1292fe8fb19SBen Grasup to the 1302fe8fb19SBen Grasfirst 1312fe8fb19SBen Gras.Dv NUL . 1322fe8fb19SBen GrasThe 1332fe8fb19SBen Gras.Fn strvisx 134f14fb602SLionel Sambucand 135f14fb602SLionel Sambuc.Fn strnvisx 136f14fb602SLionel Sambucfunctions encode exactly 1372fe8fb19SBen Gras.Fa len 1382fe8fb19SBen Grascharacters from 1392fe8fb19SBen Gras.Fa src 1402fe8fb19SBen Gras(this 1412fe8fb19SBen Grasis useful for encoding a block of data that may contain 1422fe8fb19SBen Gras.Dv NUL Ns 's ) . 1432fe8fb19SBen GrasBoth forms 1442fe8fb19SBen Gras.Dv NUL 1452fe8fb19SBen Grasterminate 1462fe8fb19SBen Gras.Fa dst . 1472fe8fb19SBen GrasThe size of 1482fe8fb19SBen Gras.Fa dst 1492fe8fb19SBen Grasmust be four times the number 15084d9c625SLionel Sambucof bytes encoded from 1512fe8fb19SBen Gras.Fa src 1522fe8fb19SBen Gras(plus one for the 1532fe8fb19SBen Gras.Dv NUL ) . 1542fe8fb19SBen GrasBoth 15584d9c625SLionel Sambucforms return the number of characters in 15684d9c625SLionel Sambuc.Fa dst 15784d9c625SLionel Sambuc(not including the trailing 1582fe8fb19SBen Gras.Dv NUL ) . 159f14fb602SLionel SambucThe 16084d9c625SLionel Sambuc.Dq Nm n 161f14fb602SLionel Sambucversions of the functions also take an additional argument 162f14fb602SLionel Sambuc.Fa dlen 163f14fb602SLionel Sambucthat indicates the length of the 164f14fb602SLionel Sambuc.Fa dst 165f14fb602SLionel Sambucbuffer. 166f14fb602SLionel SambucIf 167f14fb602SLionel Sambuc.Fa dlen 16884d9c625SLionel Sambucis not large enough to fit the converted string then the 169f14fb602SLionel Sambuc.Fn strnvis 170f14fb602SLionel Sambucand 171f14fb602SLionel Sambuc.Fn strnvisx 172f14fb602SLionel Sambucfunctions return \-1 and set 173f14fb602SLionel Sambuc.Va errno 174f14fb602SLionel Sambucto 175f14fb602SLionel Sambuc.Dv ENOSPC . 17684d9c625SLionel SambucThe 17784d9c625SLionel Sambuc.Fn strenvisx 17884d9c625SLionel Sambucfunction takes an additional argument, 17984d9c625SLionel Sambuc.Fa cerr_ptr , 18084d9c625SLionel Sambucthat is used to pass in and out a multibyte conversion error flag. 18184d9c625SLionel SambucThis is useful when processing single characters at a time when 18284d9c625SLionel Sambucit is possible that the locale may be set to something other 18384d9c625SLionel Sambucthan the locale of the characters in the input data. 1842fe8fb19SBen Gras.Pp 1852fe8fb19SBen GrasThe functions 1862fe8fb19SBen Gras.Fn svis , 187f14fb602SLionel Sambuc.Fn snvis , 1882fe8fb19SBen Gras.Fn strsvis , 189f14fb602SLionel Sambuc.Fn strsnvis , 190f14fb602SLionel Sambuc.Fn strsvisx , 19184d9c625SLionel Sambuc.Fn strsnvisx , 1922fe8fb19SBen Grasand 19384d9c625SLionel Sambuc.Fn strsenvisx 1942fe8fb19SBen Grascorrespond to 1952fe8fb19SBen Gras.Fn vis , 196f14fb602SLionel Sambuc.Fn nvis , 1972fe8fb19SBen Gras.Fn strvis , 198f14fb602SLionel Sambuc.Fn strnvis , 199f14fb602SLionel Sambuc.Fn strvisx , 20084d9c625SLionel Sambuc.Fn strnvisx , 2012fe8fb19SBen Grasand 20284d9c625SLionel Sambuc.Fn strenvisx 2032fe8fb19SBen Grasbut have an additional argument 2042fe8fb19SBen Gras.Fa extra , 2052fe8fb19SBen Graspointing to a 2062fe8fb19SBen Gras.Dv NUL 2072fe8fb19SBen Grasterminated list of characters. 2082fe8fb19SBen GrasThese characters will be copied encoded or backslash-escaped into 2092fe8fb19SBen Gras.Fa dst . 2102fe8fb19SBen GrasThese functions are useful e.g. to remove the special meaning 2112fe8fb19SBen Grasof certain characters to shells. 2122fe8fb19SBen Gras.Pp 2132fe8fb19SBen GrasThe encoding is a unique, invertible representation composed entirely of 2142fe8fb19SBen Grasgraphic characters; it can be decoded back into the original form using 2152fe8fb19SBen Grasthe 216f14fb602SLionel Sambuc.Xr unvis 3 , 2172fe8fb19SBen Gras.Xr strunvis 3 218f14fb602SLionel Sambucor 219f14fb602SLionel Sambuc.Xr strnunvis 3 2202fe8fb19SBen Grasfunctions. 2212fe8fb19SBen Gras.Pp 2222fe8fb19SBen GrasThere are two parameters that can be controlled: the range of 2232fe8fb19SBen Grascharacters that are encoded (applies only to 2242fe8fb19SBen Gras.Fn vis , 225f14fb602SLionel Sambuc.Fn nvis , 2262fe8fb19SBen Gras.Fn strvis , 227f14fb602SLionel Sambuc.Fn strnvis , 228f14fb602SLionel Sambuc.Fn strvisx , 2292fe8fb19SBen Grasand 230f14fb602SLionel Sambuc.Fn strnvisx ) , 2312fe8fb19SBen Grasand the type of representation used. 2322fe8fb19SBen GrasBy default, all non-graphic characters, 23384d9c625SLionel Sambucexcept space, tab, and newline are encoded (see 23484d9c625SLionel Sambuc.Xr isgraph 3 ) . 2352fe8fb19SBen GrasThe following flags 2362fe8fb19SBen Grasalter this: 2372fe8fb19SBen Gras.Bl -tag -width VIS_WHITEX 23884d9c625SLionel Sambuc.It Dv VIS_GLOB 23984d9c625SLionel SambucAlso encode the magic characters 24084d9c625SLionel Sambuc.Ql ( * , 24184d9c625SLionel Sambuc.Ql \&? , 242*0a6a1f1dSLionel Sambuc.Ql \&[ , 24384d9c625SLionel Sambucand 24484d9c625SLionel Sambuc.Ql # ) 24584d9c625SLionel Sambucrecognized by 24684d9c625SLionel Sambuc.Xr glob 3 . 247*0a6a1f1dSLionel Sambuc.It Dv VIS_SHELL 248*0a6a1f1dSLionel SambucAlso encode the meta characters used by shells (in addition to the glob 249*0a6a1f1dSLionel Sambuccharacters): 250*0a6a1f1dSLionel Sambuc.Ql ( ' , 251*0a6a1f1dSLionel Sambuc.Ql ` , 252*0a6a1f1dSLionel Sambuc.Ql \&" , 253*0a6a1f1dSLionel Sambuc.Ql \&; , 254*0a6a1f1dSLionel Sambuc.Ql & , 255*0a6a1f1dSLionel Sambuc.Ql < , 256*0a6a1f1dSLionel Sambuc.Ql > , 257*0a6a1f1dSLionel Sambuc.Ql \&( , 258*0a6a1f1dSLionel Sambuc.Ql \&) , 259*0a6a1f1dSLionel Sambuc.Ql \&| , 260*0a6a1f1dSLionel Sambuc.Ql \&] , 261*0a6a1f1dSLionel Sambuc.Ql \e , 262*0a6a1f1dSLionel Sambuc.Ql $ , 263*0a6a1f1dSLionel Sambuc.Ql \&! , 264*0a6a1f1dSLionel Sambuc.Ql \&^ , 265*0a6a1f1dSLionel Sambucand 266*0a6a1f1dSLionel Sambuc.Ql ~ ) . 2672fe8fb19SBen Gras.It Dv VIS_SP 2682fe8fb19SBen GrasAlso encode space. 2692fe8fb19SBen Gras.It Dv VIS_TAB 2702fe8fb19SBen GrasAlso encode tab. 2712fe8fb19SBen Gras.It Dv VIS_NL 2722fe8fb19SBen GrasAlso encode newline. 2732fe8fb19SBen Gras.It Dv VIS_WHITE 2742fe8fb19SBen GrasSynonym for 275*0a6a1f1dSLionel Sambuc.Dv VIS_SP | VIS_TAB | VIS_NL . 276*0a6a1f1dSLionel Sambuc.It Dv VIS_META 277*0a6a1f1dSLionel SambucSynonym for 278*0a6a1f1dSLionel Sambuc.Dv VIS_WHITE | VIS_GLOB | VIS_SHELL . 2792fe8fb19SBen Gras.It Dv VIS_SAFE 28084d9c625SLionel SambucOnly encode 28184d9c625SLionel Sambuc.Dq unsafe 28284d9c625SLionel Sambuccharacters. 2832fe8fb19SBen GrasUnsafe means control characters which may cause common terminals to perform 2842fe8fb19SBen Grasunexpected functions. 2852fe8fb19SBen GrasCurrently this form allows space, tab, newline, backspace, bell, and 28684d9c625SLionel Sambucreturn \(em in addition to all graphic characters \(em unencoded. 2872fe8fb19SBen Gras.El 2882fe8fb19SBen Gras.Pp 2892fe8fb19SBen Gras(The above flags have no effect for 2902fe8fb19SBen Gras.Fn svis , 291f14fb602SLionel Sambuc.Fn snvis , 2922fe8fb19SBen Gras.Fn strsvis , 293f14fb602SLionel Sambuc.Fn strsnvis , 294f14fb602SLionel Sambuc.Fn strsvisx , 2952fe8fb19SBen Grasand 296f14fb602SLionel Sambuc.Fn strsnvisx . 2972fe8fb19SBen GrasWhen using these functions, place all graphic characters to be 2982fe8fb19SBen Grasencoded in an array pointed to by 2992fe8fb19SBen Gras.Fa extra . 3002fe8fb19SBen GrasIn general, the backslash character should be included in this array, see the 3012fe8fb19SBen Graswarning on the use of the 3022fe8fb19SBen Gras.Dv VIS_NOSLASH 3032fe8fb19SBen Grasflag below). 3042fe8fb19SBen Gras.Pp 3052fe8fb19SBen GrasThere are four forms of encoding. 3062fe8fb19SBen GrasAll forms use the backslash character 3072fe8fb19SBen Gras.Ql \e 3082fe8fb19SBen Grasto introduce a special 3092fe8fb19SBen Grassequence; two backslashes are used to represent a real backslash, 3102fe8fb19SBen Grasexcept 3112fe8fb19SBen Gras.Dv VIS_HTTPSTYLE 3122fe8fb19SBen Grasthat uses 3132fe8fb19SBen Gras.Ql % , 3142fe8fb19SBen Grasor 3152fe8fb19SBen Gras.Dv VIS_MIMESTYLE 3162fe8fb19SBen Grasthat uses 3172fe8fb19SBen Gras.Ql = . 3182fe8fb19SBen GrasThese are the visual formats: 3192fe8fb19SBen Gras.Bl -tag -width VIS_CSTYLE 3202fe8fb19SBen Gras.It (default) 3212fe8fb19SBen GrasUse an 3222fe8fb19SBen Gras.Ql M 3232fe8fb19SBen Grasto represent meta characters (characters with the 8th 3242fe8fb19SBen Grasbit set), and use caret 3252fe8fb19SBen Gras.Ql ^ 32684d9c625SLionel Sambucto represent control characters (see 32784d9c625SLionel Sambuc.Xr iscntrl 3 ) . 3282fe8fb19SBen GrasThe following formats are used: 3292fe8fb19SBen Gras.Bl -tag -width xxxxx 3302fe8fb19SBen Gras.It Dv \e^C 3312fe8fb19SBen GrasRepresents the control character 3322fe8fb19SBen Gras.Ql C . 3332fe8fb19SBen GrasSpans characters 3342fe8fb19SBen Gras.Ql \e000 3352fe8fb19SBen Grasthrough 3362fe8fb19SBen Gras.Ql \e037 , 3372fe8fb19SBen Grasand 3382fe8fb19SBen Gras.Ql \e177 3392fe8fb19SBen Gras(as 3402fe8fb19SBen Gras.Ql \e^? ) . 3412fe8fb19SBen Gras.It Dv \eM-C 3422fe8fb19SBen GrasRepresents character 3432fe8fb19SBen Gras.Ql C 3442fe8fb19SBen Graswith the 8th bit set. 3452fe8fb19SBen GrasSpans characters 3462fe8fb19SBen Gras.Ql \e241 3472fe8fb19SBen Grasthrough 3482fe8fb19SBen Gras.Ql \e376 . 3492fe8fb19SBen Gras.It Dv \eM^C 3502fe8fb19SBen GrasRepresents control character 3512fe8fb19SBen Gras.Ql C 3522fe8fb19SBen Graswith the 8th bit set. 3532fe8fb19SBen GrasSpans characters 3542fe8fb19SBen Gras.Ql \e200 3552fe8fb19SBen Grasthrough 3562fe8fb19SBen Gras.Ql \e237 , 3572fe8fb19SBen Grasand 3582fe8fb19SBen Gras.Ql \e377 3592fe8fb19SBen Gras(as 3602fe8fb19SBen Gras.Ql \eM^? ) . 3612fe8fb19SBen Gras.It Dv \e040 3622fe8fb19SBen GrasRepresents 3632fe8fb19SBen Gras.Tn ASCII 3642fe8fb19SBen Grasspace. 3652fe8fb19SBen Gras.It Dv \e240 3662fe8fb19SBen GrasRepresents Meta-space. 3672fe8fb19SBen Gras.El 3682fe8fb19SBen Gras.Pp 3692fe8fb19SBen Gras.It Dv VIS_CSTYLE 3702fe8fb19SBen GrasUse C-style backslash sequences to represent standard non-printable 3712fe8fb19SBen Grascharacters. 3722fe8fb19SBen GrasThe following sequences are used to represent the indicated characters: 3732fe8fb19SBen Gras.Bd -unfilled -offset indent 37484d9c625SLionel Sambuc.Li \ea Tn \(em BEL No (007) 37584d9c625SLionel Sambuc.Li \eb Tn \(em BS No (010) 37684d9c625SLionel Sambuc.Li \ef Tn \(em NP No (014) 37784d9c625SLionel Sambuc.Li \en Tn \(em NL No (012) 37884d9c625SLionel Sambuc.Li \er Tn \(em CR No (015) 37984d9c625SLionel Sambuc.Li \es Tn \(em SP No (040) 38084d9c625SLionel Sambuc.Li \et Tn \(em HT No (011) 38184d9c625SLionel Sambuc.Li \ev Tn \(em VT No (013) 38284d9c625SLionel Sambuc.Li \e0 Tn \(em NUL No (000) 3832fe8fb19SBen Gras.Ed 3842fe8fb19SBen Gras.Pp 38584d9c625SLionel SambucWhen using this format, the 38684d9c625SLionel Sambuc.Fa nextc 38784d9c625SLionel Sambucparameter is looked at to determine if a 3882fe8fb19SBen Gras.Dv NUL 3892fe8fb19SBen Grascharacter can be encoded as 3902fe8fb19SBen Gras.Ql \e0 3912fe8fb19SBen Grasinstead of 3922fe8fb19SBen Gras.Ql \e000 . 3932fe8fb19SBen GrasIf 3942fe8fb19SBen Gras.Fa nextc 3952fe8fb19SBen Grasis an octal digit, the latter representation is used to 3962fe8fb19SBen Grasavoid ambiguity. 3972fe8fb19SBen Gras.It Dv VIS_OCTAL 3982fe8fb19SBen GrasUse a three digit octal sequence. 3992fe8fb19SBen GrasThe form is 4002fe8fb19SBen Gras.Ql \eddd 4012fe8fb19SBen Graswhere 4022fe8fb19SBen Gras.Em d 4032fe8fb19SBen Grasrepresents an octal digit. 4042fe8fb19SBen Gras.It Dv VIS_HTTPSTYLE 4052fe8fb19SBen GrasUse URI encoding as described in RFC 1738. 4062fe8fb19SBen GrasThe form is 4072fe8fb19SBen Gras.Ql %xx 4082fe8fb19SBen Graswhere 4092fe8fb19SBen Gras.Em x 4102fe8fb19SBen Grasrepresents a lower case hexadecimal digit. 4112fe8fb19SBen Gras.It Dv VIS_MIMESTYLE 4122fe8fb19SBen GrasUse MIME Quoted-Printable encoding as described in RFC 2045, only don't 4132fe8fb19SBen Grasbreak lines and don't handle CRLF. 41484d9c625SLionel SambucThe form is 41584d9c625SLionel Sambuc.Ql =XX 4162fe8fb19SBen Graswhere 4172fe8fb19SBen Gras.Em X 4182fe8fb19SBen Grasrepresents an upper case hexadecimal digit. 4192fe8fb19SBen Gras.El 4202fe8fb19SBen Gras.Pp 4212fe8fb19SBen GrasThere is one additional flag, 4222fe8fb19SBen Gras.Dv VIS_NOSLASH , 4232fe8fb19SBen Graswhich inhibits the 4242fe8fb19SBen Grasdoubling of backslashes and the backslash before the default 4252fe8fb19SBen Grasformat (that is, control characters are represented by 4262fe8fb19SBen Gras.Ql ^C 4272fe8fb19SBen Grasand 4282fe8fb19SBen Grasmeta characters as 4292fe8fb19SBen Gras.Ql M-C ) . 4302fe8fb19SBen GrasWith this flag set, the encoding is 4312fe8fb19SBen Grasambiguous and non-invertible. 43284d9c625SLionel Sambuc.Sh MULTIBYTE CHARACTER SUPPORT 43384d9c625SLionel SambucThese functions support multibyte character input. 43484d9c625SLionel SambucThe encoding conversion is influenced by the setting of the 43584d9c625SLionel Sambuc.Ev LC_CTYPE 43684d9c625SLionel Sambucenvironment variable which defines the set of characters 43784d9c625SLionel Sambucthat can be copied without encoding. 43884d9c625SLionel Sambuc.Pp 439*0a6a1f1dSLionel SambucIf 440*0a6a1f1dSLionel Sambuc.Dv VIS_NOLOCALE 441*0a6a1f1dSLionel Sambucis set, processing is done assuming the C locale and overriding 442*0a6a1f1dSLionel Sambucany other environment settings. 443*0a6a1f1dSLionel Sambuc.Pp 44484d9c625SLionel SambucWhen 8-bit data is present in the input, 44584d9c625SLionel Sambuc.Ev LC_CTYPE 44684d9c625SLionel Sambucmust be set to the correct locale or to the C locale. 44784d9c625SLionel SambucIf the locales of the data and the conversion are mismatched, 44884d9c625SLionel Sambucmultibyte character recognition may fail and encoding will be performed 44984d9c625SLionel Sambucbyte-by-byte instead. 45084d9c625SLionel Sambuc.Pp 45184d9c625SLionel SambucAs noted above, 45284d9c625SLionel Sambuc.Fa dst 45384d9c625SLionel Sambucmust be four times the number of bytes processed from 45484d9c625SLionel Sambuc.Fa src . 45584d9c625SLionel SambucBut note that each multibyte character can be up to 45684d9c625SLionel Sambuc.Dv MB_LEN_MAX 45784d9c625SLionel Sambucbytes 45884d9c625SLionel Sambuc.\" (see 45984d9c625SLionel Sambuc.\" .Xr multibyte 3 ) 46084d9c625SLionel Sambucso in terms of multibyte characters, 46184d9c625SLionel Sambuc.Fa dst 46284d9c625SLionel Sambucmust be four times 46384d9c625SLionel Sambuc.Dv MB_LEN_MAX 46484d9c625SLionel Sambuctimes the number of characters processed from 46584d9c625SLionel Sambuc.Fa src . 46684d9c625SLionel Sambuc.Sh ENVIRONMENT 46784d9c625SLionel Sambuc.Bl -tag -width ".Ev LC_CTYPE" 46884d9c625SLionel Sambuc.It Ev LC_CTYPE 46984d9c625SLionel SambucSpecify the locale of the input data. 47084d9c625SLionel SambucSet to C if the input data locale is unknown. 47184d9c625SLionel Sambuc.El 472f14fb602SLionel Sambuc.Sh ERRORS 473f14fb602SLionel SambucThe functions 474f14fb602SLionel Sambuc.Fn nvis 475f14fb602SLionel Sambucand 476f14fb602SLionel Sambuc.Fn snvis 477f14fb602SLionel Sambucwill return 478f14fb602SLionel Sambuc.Dv NULL 479f14fb602SLionel Sambucand the functions 480f14fb602SLionel Sambuc.Fn strnvis , 481f14fb602SLionel Sambuc.Fn strnvisx , 482f14fb602SLionel Sambuc.Fn strsnvis , 483f14fb602SLionel Sambucand 484f14fb602SLionel Sambuc.Fn strsnvisx , 485f14fb602SLionel Sambucwill return \-1 when the 486f14fb602SLionel Sambuc.Fa dlen 48784d9c625SLionel Sambucdestination buffer size is not enough to perform the conversion while 488f14fb602SLionel Sambucsetting 489f14fb602SLionel Sambuc.Va errno 490f14fb602SLionel Sambucto: 49184d9c625SLionel Sambuc.Bl -tag -width ".Bq Er ENOSPC" 492f14fb602SLionel Sambuc.It Bq Er ENOSPC 493f14fb602SLionel SambucThe destination buffer size is not large enough to perform the conversion. 494f14fb602SLionel Sambuc.El 4952fe8fb19SBen Gras.Sh SEE ALSO 4962fe8fb19SBen Gras.Xr unvis 1 , 4972fe8fb19SBen Gras.Xr vis 1 , 49884d9c625SLionel Sambuc.Xr glob 3 , 49984d9c625SLionel Sambuc.\" .Xr multibyte 3 , 5002fe8fb19SBen Gras.Xr unvis 3 5012fe8fb19SBen Gras.Rs 5022fe8fb19SBen Gras.%A T. Berners-Lee 5032fe8fb19SBen Gras.%T Uniform Resource Locators (URL) 50484d9c625SLionel Sambuc.%O "RFC 1738" 50584d9c625SLionel Sambuc.Re 50684d9c625SLionel Sambuc.Rs 50784d9c625SLionel Sambuc.%T "Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies" 50884d9c625SLionel Sambuc.%O "RFC 2045" 5092fe8fb19SBen Gras.Re 5102fe8fb19SBen Gras.Sh HISTORY 5112fe8fb19SBen GrasThe 512f14fb602SLionel Sambuc.Fn vis , 513f14fb602SLionel Sambuc.Fn strvis , 5142fe8fb19SBen Grasand 51584d9c625SLionel Sambuc.Fn strvisx 5162fe8fb19SBen Grasfunctions first appeared in 5172fe8fb19SBen Gras.Bx 4.4 . 5182fe8fb19SBen GrasThe 519f14fb602SLionel Sambuc.Fn svis , 520f14fb602SLionel Sambuc.Fn strsvis , 5212fe8fb19SBen Grasand 522f14fb602SLionel Sambuc.Fn strsvisx 5232fe8fb19SBen Grasfunctions appeared in 5242fe8fb19SBen Gras.Nx 1.5 . 525f14fb602SLionel SambucThe buffer size limited versions of the functions 526f14fb602SLionel Sambuc.Po Fn nvis , 527f14fb602SLionel Sambuc.Fn strnvis , 528f14fb602SLionel Sambuc.Fn strnvisx , 529f14fb602SLionel Sambuc.Fn snvis , 530f14fb602SLionel Sambuc.Fn strsnvis , 531f14fb602SLionel Sambucand 532f14fb602SLionel Sambuc.Fn strsnvisx Pc 533f14fb602SLionel Sambucappeared in 53484d9c625SLionel Sambuc.Nx 6.0 53584d9c625SLionel Sambucand 53684d9c625SLionel Sambuc.Fx 9.2 . 53784d9c625SLionel SambucMyltibyte character support was added in 53884d9c625SLionel Sambuc.Nx 7.0 53984d9c625SLionel Sambucand 54084d9c625SLionel Sambuc.Fx 9.2 . 541