daveyarwood / djy

A library of character utility functions for Clojure
Eclipse Public License 1.0
37 stars 3 forks source link

`code-point-of` with Integers #1

Closed trptcolin closed 9 years ago

trptcolin commented 9 years ago

char-seq doesn't seem to work for me. This is on Clojure 1.6, Java 1.7.

user=> (require '[djy.char :as c])
nil
user=> (c/char' 120121)
"𝔹"
user=> (c/char-seq (c/char' 120121))
IllegalArgumentException No method in multimethod 'code-point-of' for dispatch value: class java.lang.Integer  clojure.lang.MultiFn.getFn (MultiFn.java:160)

Adding a defmethod to code-point-of for java.lang.Integer fixes the issue for me locally.

daveyarwood commented 9 years ago

Good catch! I'm playing around with it a little now, and it looks like the issue is that the Java String method codePointAt returns an Integer, not a Long. Seems like I could fix this by changing the code-point-of implementation for java.lang.Long to be for java.lang.Number instead. Interestingly, clojure.core/char works with floating-point numbers too -- it just rounds them off, so (accidentally) opening up the possibility of using a floating-point number as an argument to code-point-of doesn't seem to break anything.

trptcolin commented 9 years ago

Yeah java.lang.Number seems good to me.