How do I convert a character to its ASCII code?

By passing the integer type symbol, `int, as the left argument to the $ (cast) operator:

q)`int $ "A"
65
q)

You can convert a list of characters at once:

q)`int $ "Hello, world!"
72 101 108 108 111 44 32 119 111 114 108 100 33
q)

Alternatively, the left argument to $ (cast) can also be the integer type character, “i” or type value 6h:

q)"i" $ "Hello, world!"
72 101 108 108 111 44 32 119 111 114 108 100 33
q)
q)type 1 2 3
6h
q)6h $ "Hello, world!"
72 101 108 108 111 44 32 119 111 114 108 100 33
q)

See also: Unicode, UTF-8