Reputation: 301
user=> (char 65)
\A
user=> (char 97)
\a
user=> (str (char 65))
"A"
user=> (str (char 97))
"a"
These are the characters from the ascii decimal values ... How do I get the ascii decimal values from the characters?
Upvotes: 13
Views: 10069
Reputation: 12883
A character is a number, it's just that clojure is showing it to you as a char. The easiest way is to just cast that char to an int.
e.g.
user=> (int \A)
65
user=> (int (.charAt "A" 0))
65
Upvotes: 15
Reputation: 40145
user=> (doseq [c "aA"] (printf "%d%n" (int c)))
97
65
nil
user=> (map int "aA");;
(97 65)
user=> (apply str (map char [97 65]))
"aA"
Upvotes: 12