gawk: Extension Sample Ord
1
1 16.7.5 Character and Numeric values: 'ord()' and 'chr()'
1 --------------------------------------------------------
1
1 The 'ordchr' extension adds two functions, named 'ord()' and 'chr()', as
1 follows:
1
1 '@load "ordchr"'
1 This is how you load the extension.
1
1 'number = ord(string)'
1 Return the numeric value of the first character in 'string'.
1
1 'char = chr(number)'
1 Return a string whose first character is that represented by
1 'number'.
1
1 These functions are inspired by the Pascal language functions of the
1 same name. Here is an example:
1
1 @load "ordchr"
1 ...
1 printf("The numeric value of 'A' is %d\n", ord("A"))
1 printf("The string value of 65 is %s\n", chr(65))
1