« What exactly does column-oriented mean? | Main | I'm in a hurry. Can multiple kdb processes write simultaneously to a splayed database? »

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

PrintView Printer Friendly Version

EmailEmail Article to Friend

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
All HTML will be escaped. Textile formatting is allowed.