SYNOPSIS
#include <vis.h>
char *vis(char *dst, char c, int flag, char nextc);
char *nvis(char *dst, size_t dlen, int c, int flag, int nextc);
int strvis(char *dst, const char *src, int flag);
int stravis(char **dst, const char *src, int flag);
int strnvis(char *dst, size_t dlen, const char *src, int flag);
int strvisx(char *dst, const char *src, size_t len, int flag);
int strnvisx(char *dst, size_t dlen, const char *src, size_t len, int flag);
int strenvisx(char *dst, size_t dlen, const char *src, size_t len, int flag, int *cerr_ptr);
char *svis(char *dst, int c, int flag, int nextc, const char *extra);
char *snvis(char *dst, size_t dlen, int c, int flag, int nextc, const char *extra);
int strsvis(char *dst, const char *src, int flag, const char *extra);
int strsnvis(char *dst, size_t dlen, const char *src, int flag, const char *extra);
int strsvisx(char *dst, const char *src, size_t len, int flag, const char *extra);
int strsnvisx(char *dst, size_t dlen, const char *src, size_t len, int flag, const char *extra);
int strsenvisx(char *dst, size_t dlen, const char *src, size_t len, int flag, const char *extra, int *cerr_ptr);
DESCRIPTION
The
The
The functions
The encoding is a unique, invertible representation composed entirely of
graphic characters; it can be decoded back into the original form using
the
There are two parameters that can be controlled: the range of characters
that are encoded (applies only to vis(), nvis(), strvis(), strnvis(),
strvisx(), and strnvisx()), and the type of representation used. By
default, all non-graphic characters, except space, tab, and newline are
encoded (see
- VIS_GLOB
-
Also encode the magic characters ('*', '?', '[' and '#') recognized by
glob() . - 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. Unsafe means control characters which may cause common terminals to perform unexpected functions. Currently this form allows space, tab, newline, backspace, bell, and return - in addition to all graphic characters - unencoded.
(The above flags have no effect for
There are four forms of encoding. All forms use the backslash character '\' to introduce a special sequence; two backslashes are used to repre- sent a real backslash, except VIS_HTTPSTYLE that uses '%', or VIS_MIMESTYLE that uses '='. These are the visual formats:
- <default>
-
Use an 'M' to represent meta characters (characters with the 8th bit set), and use carat '^' to represent control characters (see
iscntrl() ). The following formats are used:- \^C
-
Represents the control character 'C'. Spans characters '\000' through '\037', and '\177' (as '\^?').
- \M-C
-
Represents character 'C' with the 8th bit set. Spans characters '\241' through '\376'.
- \M^C
-
Represents control character 'C' with the 8th bit set. Spans characters '\200' through '\237', and '\377' (as '\M^?')
- \040
-
Represents ASCII space.
- \240
-
Represents meta-space.
- VIS_CSTYLE
-
Use C-style backslash sequences to represent standard non-printable characters. The following sequences are used to represent the indicated characters:
\a BEL (007) \b BS (010) \f NP (014) \n NL (012) \r CR (015) \s SP (040) \t HT (011) \v VT (013) \0 NUL (000)
When using this format, the nextc parameter is looked at to determine if a null character chan be encoded as '\0' instead of '\000'. If nextc is an octal digit, the latter representation is used to avoid ambiguity.
- VIS_OCTAL
-
Use a three digit octal sequence. The form is '\ddd' where d represents an octal digit.
- VIS_HTTPSTYLE
-
Use URI encoding as described in RFC 1738. The form is '%xx' where x represents a lower case hexadecimal digit.
- VIS_MIMESTYLE
-
Use MIME Quoted-Printable encoding as described in RFC 2045, only don't break lines and don't handle CRLF. The form is '=XX' where X represents an upper case hexadecimal digit.
There is one additional flag, VIS_NOSLASH, which inhibits the doubling of backslashes and the backslash before the default format (that is, control characters are represented by '^C' and meta characters as 'M-C'). With this flag set, the encoding is ambiguous and non-invertible.
MULTIBYTE CHARACTER SUPPORT
These functions support multibyte character input. The encoding conversion is influenced by the setting of the LC_CTYPE environment variable which defines the set of characters that can be copied without encoding.
When 8-bit data is present in the input, LC_CTYPE must be set to the cor- rect locale or to the C locale. If the locales of the data and the con- version are mismatched, multibyte character recognition may fail and encoding will be performed byte-by-byte instead.
As noted above, dst must be four times the number of bytes processed from src. But note that each multibyte character can be up to MB_LEN_MAX bytes so in terms of multibyte characters, dst must be four times MB_LEN_MAX times the number of characters processed from src.`
PARAMETERS
- dst
-
Is the buffer into which the result of the encoding is stored.
- dlen
-
Size in characters of dst buffer.
- c
-
Is the character to encode.
- flag
-
Is one or more of the flags listed in the DESCRIPTION section, bitwise-OR'd together.
- nextc
-
Is the next character in the sequence, for use with VIS_CSTYLE is specified in flag.
- src
-
Is the source string to be encoded.
- len
-
Is the exact number of characters to be encoded.
RETURN VALUES
The
The functions
ENVIRONMENT
CONFORMANCE
The
MULTITHREAD SAFETY LEVEL
MT-Safe.
PORTING ISSUES
None.
AVAILABILITY
PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition
SEE ALSO
- Functions:
glob() ,strunvis() ,unvis()
PTC MKS Toolkit 10.5 Documentation Build 40.