3

In the clojure repl I can do:

=> (int \a)
97

In closurescript, I keep getting

=> (int \a)
0

In my current clojurescript project I've defined a var:

(def ord-a (int \a))

When I inspect the emitted javascript I see:

ord_a = ("a" | (0));

Which explains the discrepancy, but doesn't really do what I want. So:

  1. What am I doing wrong here?
  2. How do I get the ordinal/int/ascii value of a character in clojurescript?
user12341234
  • 6,573
  • 6
  • 23
  • 48

1 Answers1

8

Clojurescript does not have character literals.

As described here you can get it using js interop:

=> (.charCodeAt \a 0)
97
Community
  • 1
  • 1
kongeor
  • 712
  • 1
  • 6
  • 14