2010/8/10 limux <liumengji...@gmail.com>:
> There is some chinese chararters in the tables. I want to display them
> by hiccup, but browser display those chinese character as ???.

I spoke to him on #clojure and from what I could tell from some
experiments I asked him to run:

(map int "刘孟江") -> (21016 23391 27743)
    => no source file encoding issues

(.name (java.nio.charset.Charset/defaultCharset)) -> "GBK"
    => his OS default encoding is GBK ("GBK is an extension of the
GB2312 character set for simplified Chinese characters, used in the
People's Republic of China.")
         some libs might erroneously rely on that the OS default
encoding is UTF-8 or something else

(defroutes app (GET "/" [] (java.io.ByteArrayInputStream. (.getBytes
"<html><head><meta http-equiv='Content-Type' content='text/html;
charset=UTF-8'></head><body>刘孟江</body></html>" "UTF-8")))) -> showed
up correctly
    => works, since we do the encoding ourselves

(defroutes app (GET "/" [] "<html><head><meta
http-equiv='Content-Type' content='text/html;
charset=UTF-8'></head><body>刘孟江</body></html>")) -> showed up
correctly
    => ring uses UTF-8 as the default encoding no matter what the OS
default is. a very reasonable behavior, since then the result is
always deterministic.

This leaves me to the conclusion that the error is caused by hiccup
somehow (which he also used), since everything seems to work fine
without it. I might look into this later this evening to see if I can
reproduce the error that occurred for him.

// raek, your encoding wizard

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to