emulating ".ascii" with Awk

Joel West joel at bonnie.UUCP
Sat Jan 11 02:47:23 AEST 1986


I need help getting awk to print out the numeric value of a character.

I've already written a csh/awk processor to convert error message
text to pre-assembled strings in assembly language (it's not
C, so don't tell me to use static char *).

However, while this works fine for BSD, where I can
	.ascii	"abcdef"
I have been unable to get it to work for System V, where I need:
	.byte	97,98,99,100,101...
Unfortunately, printing a character as "%d" with printf
gives me a "0".

What I need is one of two things:

	1) Print the numeric value of an ascii character as an
	   integer from awk(1); or
	2) Be able to pipe a string to a command (say "asbyte")
	   which has the following property:
		"asbyte abcd" prints "97,98,99,100"

I'm running awk under BSD 4.2, if there are different versions.
-- 
	Joel West
	CACI, Inc. - Federal La Jolla  (c/o Bell Labs, Whipanny)
	ihnp4!bonnie!joel



More information about the Comp.unix mailing list