Character codes: Difference between revisions

(added standard ml)
Line 33:
file/tape. eg.
<lang algol> make conv(tape, stand conv(stand out channel))</lang>
 
=={{header|AWK}}==
 
AWK has not built-in way to convert a character into ASCII (or whatever) code; but a function that does so can be easily built using an associative array (where the keys are the characters). The opposite can be done using <tt>printf</tt> (or <tt>sprintf</tt>) with <tt>%c</tt>
 
<lang awk>function ord(c)
{
return chmap[c]
}
BEGIN {
for(i=0; i < 256; i++) {
chmap[sprintf("%c", i)] = i
}
print ord("a"), ord("b")
printf "%c %c\n", 97, 98
s = sprintf("%c%c", 97, 98)
print s
}</lang>
 
=={{header|BASIC}}==