diff options
-rw-r--r-- | src/clojure/contrib/str_utils2.clj | 2 | ||||
-rw-r--r-- | src/clojure/contrib/test_contrib/str_utils2.clj | 9 |
2 files changed, 9 insertions, 2 deletions
diff --git a/src/clojure/contrib/str_utils2.clj b/src/clojure/contrib/str_utils2.clj index ec2741ce..26dd849f 100644 --- a/src/clojure/contrib/str_utils2.clj +++ b/src/clojure/contrib/str_utils2.clj @@ -93,7 +93,7 @@ [#^String s cmap] (let [buffer (StringBuilder. (.length s))] (dochars [c s] - (if-let [r (cmap s)] + (if-let [r (cmap c)] (.append buffer r) (.append buffer c))) (.toString buffer))) diff --git a/src/clojure/contrib/test_contrib/str_utils2.clj b/src/clojure/contrib/test_contrib/str_utils2.clj index dac0893a..4b466774 100644 --- a/src/clojure/contrib/test_contrib/str_utils2.clj +++ b/src/clojure/contrib/test_contrib/str_utils2.clj @@ -41,4 +41,11 @@ (deftest t-codepoints (is (= (list 102 111 111 65536 98 97 114) (s/codepoints "foo\uD800\uDC00bar")) - "Handles Unicode supplementary characters"))) + "Handles Unicode supplementary characters")) + +(deftest t-escape + (is (= "<foo&bar>" + (s/escape "<foo&bar>" {\& "&" \< "<" \> ">"}))) + (is (= " \\\"foo\\\" " + (s/escape " \"foo\" " {\" "\\\""}))) + (is (= "faabor" (s/escape "foobar" {\a \o, \o \a})))) |