• (codepoints s)
Returns a sequence of integer Unicode code points in s. Handles
Unicode supplementary characters (above U+FFFF) correctly.

0 Examples top

Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/contrib/string.clj:78 top

(defn codepoints
  "Returns a sequence of integer Unicode code points in s.  Handles
  Unicode supplementary characters (above U+FFFF) correctly."
  [^String s]
  (let [len (.length s)
        f (fn thisfn [^String s i]
            (when (< i len)
              (let [c (.charAt s i)]
                (if (Character/isHighSurrogate c)
                  (cons (.codePointAt s i) (thisfn s (+ 2 i)))
                  (cons (int c) (thisfn s (inc i)))))))]
    (lazy-seq (f s 0))))
Vars in clojure.contrib.string/codepoints: defn lazy-seq let
Used in 0 other vars

Comments top

No comments for codepoints. Log in to add a comment.