remotes cannot receive (to clojure) some unicode characters in strings #12

Open
terjesb opened this Issue May 21, 2012 · 0 comments

Projects

None yet

1 participant

@terjesb
terjesb commented May 21, 2012

I was just bitten by this, which seems to be identical to pinot issue 16, ibdknox/pinot#16, reported by davesann. This is with latest available fetch/noir on Clojure 1.4.0, both OS X 10.7, OpenJDK 1.7 and Ubuntu 12.04, OpenJDK 1.7, and as far as I can tell everything is UTF-8.

It works fine retrieving a value like 'tésting' from the remote, but not posting the same.

There was also a discussion about read-string on the clojure list https://groups.google.com/forum/?fromgroups#!topic/clojure/Kl3WVtEE3FY, but I'm not sure if a fix there has been agreed upon yet. (The wiki page linked to there doesn't work for me right now.)

java.lang.RuntimeException: Unsupported escape character: \x
at clojure.lang.Util.runtimeException(Util.java:170)
at clojure.lang.LispReader$StringReader.invoke(LispReader.java:497)
at clojure.lang.LispReader.readDelimitedList(LispReader.java:1126)
at clojure.lang.LispReader$MapReader.invoke(LispReader.java:1069)
at clojure.lang.LispReader.readDelimitedList(LispReader.java:1126)
at clojure.lang.LispReader$VectorReader.invoke(LispReader.java:1061)
at clojure.lang.LispReader.read(LispReader.java:180)
at clojure.lang.RT.readString(RT.java:1707)
at clojure.core$read_string.invoke(core.clj:3361)
at noir.fetch.remotes$safe_read.invoke(remotes.clj:14)
at noir.fetch.remotes$ANY___fetch.invoke(remotes.clj:

I am currently investigating if davesann's proposed fix works for me:

(defn unescape [string]
  (s/replace 
    string #"\\x(..)" 
    (fn [m] (str (char (Integer/parseInt (second m) 16))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment