text: VIS(3) BSD Programmer's Manual VIS(3)
  vis, strvis, strnvis, strvisx, svis, strsvis, strnsvis, strsvisx - visu- ally encode characters
  #include <stdlib.h> #include <vis.h> char * vis(char *dst, int c, int flag, int nextc); int strvis(char *dst, const char *src, int flag); int strnvis(char *dst, const char *src, size_t size, int flag); int strvisx(char *dst, const char *src, size_t len, int flag); char * svis(char *dst, int c, int flag, int nextc, const char *extra); int strsvis(char *dst, const char *src, int flag, const char *extra); int strnsvis(char *dst, const char *src, size_t size, int flag, const char *extra); int strsvisx(char *dst, const char *src, size_t len, int flag, const char *extra);
  The vis() function copies into dst a string which represents the charac- ter c. If c needs no encoding, it is copied in unaltered. The string is NUL() and strvisx() functions copy into dst a visual representation of the string src. The strvis() function encodes charac- ters from src up to the first NUL. The strnvis() function encodes charac- ters from src up to the first NUL or the end of dst, as indicated by size. The strvisx() function encodes exactly len characters from src (this is useful for encoding a block of data that may contain NULs). All three forms NUL terminate dst, except for strnvis() when size is zero, in which case dst is not touched. For strvis() and strvisx(), the size of dst must be four times the number of characters encoded from src (plus one for the NUL). strvis() and strvisx() return the number of characters in dst (not including the trailing NUL). strnvis() returns the length that dst would become if it were of unlimited size (similar to snprintf(3) or strlcpy(3)). This can be used to detect truncation but it also means that the return value of strnvis() must not be used without checking it against size. The functions svis(), strsvis(), strnsvis() and strsvisx() correspond to vis(), strvis(), strn(), strnvis(), and strvisx()), and the type of representation used. By default, all non- graphic characters except space, tab, and newline are encoded (see isgraph(3)). The following flags alter this: VIS_GLOB Also encode magic characters recognized by glob(3) ('*', '?', '[') and '#'. VIS_SP Also encode space. VIS_TAB Also encode tab. VIS_NL Also encode newline. VIS_WHITE Synonym for VIS_SP | VIS_TAB | VIS_NL. VIS_SAFE Only encode "unsafe" characters. These are control characters which may cause common terminals to perform unexpected func- tions. Currently this form allows space, tab, newline, back- space, bell, and return -- in addition to all graphic charac- ters -- unencoded. (The above flags have no effect for svis(), strsvis(), strns '\' charac- ter to introduce a special sequence; two backslashes are used to represent a real backslash, except VIS_HTTPSTYLE which uses '%'. These are the visual formats: (default) Use an 'M' to represent meta characters (characters with the 8th bit set), and use a caret '^' to represent control char- acters  representa- tion.
  unvis(1), vis(1), snprintf(3), strlcpy(3), unvis(3) T. Berners-Lee, Uniform Resource Locators (URL), RFC1738.
  The vis(), strvis() and strvisx() functions first appeared in 4.4BSD. The strnvis() function first appeared in OpenBSD 2.9. The svis(), strsvis(), and strsvisx() functions appeared in NetBSD 1.5. The strnsvis() function appeared in MirOS #10. MirOS BSD #10-current May 7, 2007.