Logo address

hfmt

NAME

	hfmt

SYNOPSIS

	hfmt [-ax] fmt [arg ...]

DESCRIPTION

hfmt converts input to some formated output. The format is given by ifmt. The main usage will be to convert plain string to URL encoded and HTML encoded strings.
The format string fmt is is similar to that of C language. That is, %[flags]varb.
The flags are some of the following characters: .,#+-0123456789
and the verb are one of the following characters: cdoxXeEgGfUHD
The last three flags UHD are hfmt specific. The meanings are:
Some of back slash escapes are also supported: \t \n \r \\

We have two type of usages:

where str is a string and num is a number.
Option -x means non-ascii rune is hex decoded.
In the second usage, data are read from stdin; the numbers of fhmt arguments means the field numbers. Field number "0" is special, i.e., "0" means whole line excluding trailing new line code '\n'. The command hfmt splits tokenized lines.

EXAMPLES

Example 1 Simple examples are shown below.
term% hfmt -a '%H\n' 'AT&T'
AT&T
term% hfmt -a '%U\n' 'AT&T'
AT%26T
term% hfmt -a '%D\n' `{date -n}
Sat, 01 Sep 2007 10:49:01 GMT
term%

Example 2

term% hfmt -a '%U\n' 日本
日本
term% hfmt -ax '%U\n' 日本
%E6%97%A5%E6%9C%AC
term%

Example 3 More complicated example:

term% ls -l
--rw-rw-r-- M 43 web web   24 Sep  1 22:52 'AT and T'
--rw-rw-r-- M 43 web web  254 Sep  1 19:46 'AT&T'
term% ls -l | hfmt '%6d <a href="%U">%H</a>\n' 6 10 10
    24 <a href="AT%20and%20T">AT&#032;and&#032;T</a>
   254 <a href="AT%26T">AT&amp;T</a>
term%

SOURCE

http://plan9.aichi-u.ac.jp/netlib/cgitools/

BUGS

hfmt cannot handle integers larger than 32 bits.