fetch icon indicating copy to clipboard operation
fetch copied to clipboard

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

Open terjesb opened this issue 12 years ago • 0 comments

I was just bitten by this, which seems to be identical to pinot issue 16, https://github.com/ibdknox/pinot/issues/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))))))

terjesb avatar May 21 '12 10:05 terjesb