diff options
-rw-r--r-- | lib/libc/gen/unvis.3 | 29 | ||||
-rw-r--r-- | lib/libc/gen/vis.3 | 9 |
2 files changed, 34 insertions, 4 deletions
diff --git a/lib/libc/gen/unvis.3 b/lib/libc/gen/unvis.3 index f5bb169..ba6b38b 100644 --- a/lib/libc/gen/unvis.3 +++ b/lib/libc/gen/unvis.3 @@ -47,11 +47,14 @@ .Fn unvis "char *cp" "int c" "int *astate" "int flag" .Ft int .Fn strunvis "char *dst" "const char *src" +.Ft int +.Fn strunvisx "char *dst" "const char *src" "int flag" .Sh DESCRIPTION The -.Fn unvis -and +.Fn unvis , .Fn strunvis +and +.Fn strunvisx functions are used to decode a visual representation of characters, as produced by the @@ -89,6 +92,16 @@ equal to the size of decoding). .Pp The +.Fn strunvisx +function does the same as the +.Fn strunvis +function, but it allows you to add a flag that specifies the style the string +.Ar src +is encoded with. +Currently, the only supported flag is +.Dv VIS_HTTPSTYLE . +.Pp +The .Fn unvis function implements a state machine that can be used to decode an arbitrary @@ -126,10 +139,20 @@ unknown state. The decoder is placed into the starting state. .Pp When all bytes in the stream have been processed, call .Fn unvis -one more time with flag set to +one more time with +.Ar flag +set to .Dv UNVIS_END to extract any remaining character (the character passed in is ignored). .Pp +The +.Ar flag +argument is also used to specify the encoding style of the source. +If set to +.Dv VIS_HTTPSTYLE , +.Fn unvis +will decode URI strings as specified in RFC 1808. +.Pp The following code fragment illustrates a proper use of .Fn unvis . .Bd -literal -offset indent diff --git a/lib/libc/gen/vis.3 b/lib/libc/gen/vis.3 index 88d5b52..7612bd5 100644 --- a/lib/libc/gen/vis.3 +++ b/lib/libc/gen/vis.3 @@ -162,7 +162,7 @@ All forms use the backslash character to introduce a special sequence; two backslashes are used to represent a real backslash. These are the visual formats: -.Bl -tag -width VIS_CSTYLE +.Bl -tag -width VIS_HTTPSTYLE .It (default) Use an .Ql M @@ -238,6 +238,13 @@ If .Fa nextc is an octal digit, the latter representation is used to avoid ambiguity. +.It Dv VIS_HTTPSTYLE +Use URI encoding as described in RFC 1808. +The form is +.Ql %dd +where +.Em d +represents a hexadecimal digit. .It Dv VIS_OCTAL Use a three digit octal sequence. The form is .Ql \eddd |