gprintf '\33c\e[3J'; echo; str1="apple\353\200\200A\364\220\200\200XYZ\366\230\237\277JR\355\271\272z\335\255\232F\300\210Q\343\207W"; gprintf '%s\n' "test string :: ${str1}"; echo; gprintf "${str1}" | gwc -lcm ; echo ; cmd=' gprintf "${str1}" | gawk -e '\''function hexencode(str,chr) { for(chr in b2hex) { if (chr!~/[[:alnum:]%\\]/) { gsub(chr,b2hex[chr],str) } }; return str } function octencode(str,chr) { gsub(/\\/,b2oct["\\\\"],str); gsub(/[0-7]/,"\\06&",str); for(chr in b2oct) { if(chr!~/[0-7\\]/) { gsub(chr,b2oct[chr],str) str } }; return str } BEGIN { offset=-4^4;for(x=0;x<256;x++) { byte=sprintf("%c",x+offset);b2hex[byte]=sprintf("\\x%.2X",x);b2oct[byte]=sprintf("\\%03o",x) }; spc1="/\\^[]";spc2="~!@#%&_-{}:;\42\47\140 <>,$.|()*+=?"; for(x=length(spc1);x;x--) { byte=substr(spc1,x,1); b2hex[("\\"(byte))]=b2hex[byte]; b2oct[("\\"(byte))]=b2oct[byte]; delete b2hex[byte]; delete b2oct[byte] }; for(x=length(spc2);x;x--) { byte=substr(spc2,x,1); b2hex[("["(byte)"]")]=b2hex[byte]; b2oct[("["(byte)"]")]=b2oct[byte]; delete b2hex[byte]; delete b2oct[byte] } } function printtables() { PROCINFO["sorted_in"]="@val_num_asc";cnt=4; for(x in b2oct) { printf(" %-4s:%s:%s |%s",(x~/[\040-\176]/) ? x : "[.]",b2hex[x],b2oct[x],--cnt?"":ORS); if(!cnt) { cnt=4 } } } { printf("%cinput :: |%s|%c%c non-ALNUM-hex :: %s%c%cfull-octal :: %s%c%c", 10, $0, 10, 10, hexencode($0), 10, 10, octencode($0), 10, 10); print "byte count via match($0,/$/)-1 :: " , match($0,/$/)-1; print "gsub(/./,\"&\") :: " , gsub(/./,"&"); match($0,/.*/); print "match($0,/.*/) :: ",RSTART, RLENGTH; print "length() :: ",length($0); print "split to array using empty-RE :: ", nx=split($0, arr, //); print ORS; print "($0~/^.+$/) :: " ($0~/^.+$/); print ORS; print "match($0,/.?$/) :: ",match($0,/.?$/); print ORS; for(x=1;x<=nx;x++) { printf("array cell # [ %2d ] <| %-6s | %16s | %16s |>\n", x, xa = arr[x], hexencode(xa), octencode(xa)); xa=""} } END { printtables() } '\'' 2>&1 | gcat -n ; echo; uname -a; echo; locale; echo; gawk -V; echo '; echo $'\n'"command is :: "$'\n'$'\n'"${cmd}"$'\n'; eval "${cmd}"; echo