The standard command for that is od, for octal dump (though with options, you can change from octal to decimal or hexadecimal...):
$ echo Apple | od -An -vtu1
65 112 112 108 101 10
Note that it outputs the byte value of every byte in the file. It has nothing to do with ASCII or any other character set.
If the file contains a A in a given character set, and you would like to see 65, because that's the byte used for A in ASCII, then you would need to do:
To first convert that file to ascii and then dump the corresponding byte values. For instance Apple<LF> in EBCDIC-UK would be 193 151 151 147 133 37 (301 227 227 223 205 045 in octal).
Best Answer
Define these two functions (usually available in other languages):
Usage: