Encodes non-printable, multibyte chars and a select set of printable chars as \ddd octal numbers
I.e. whitespace is encoded as the string \040
The functions available are:
vis::enc(input:str, chars_to_encode: Optional[str]) -> strvis::dec(input:str) -> str
The optional second argument to vis:enc, overrides the default set of printable characters that will be encoded.
The default set is (see also https://man.netbsd.org/vis.3 )
*? [#';"&<>()|]$!^~`\
plus \n and \t
Gawk loads extension using either:
-l <path>@load <libname>looks for lib in directory specified by envvarAWKLIBPATHcan be with or without .so/.dll suffix- See https://www.gnu.org/software/gawk/manual/html_node/Loading-Shared-Libraries.html Example:
gawk -l bazel-bin/libgawk_vis.so '
BEGIN {
print vis::enc("hello world") # hello\040world
print vis::dec("hello\040world") # hello world
print vis::enc("(◕‿◕)") # \050\342\227\225\342\200\277\342\227\225\051
}' Or with bazel run if you don't have a recent version of gawk
bazel run //:visgawk -- '
BEGIN {
print vis::enc("hello world") # hello\040world
print vis::dec("hello\040world") # hello world
print vis::enc("(◕‿◕)") # \050\342\227\225\342\200\277\342\227\225\051
}'The target //:libgawk_vis.so is a fileset with just the extension
If you just want the shared lib, run:
bazel build //:gawk_visand the sharedlib is in bazel-bin/libgawk_vis.so