2011/8/17 cran1988 <rmanolis1...@hotmail.com>: > My jvm is already UTF-8 > however it works with clojure 1.3.0 beta1 > but i have problems i get an error > NoSuchMethodError clojure.lang.KeywordLookupSite.<init>(ILclojure/lang/ > Keyword;)V clout.core/request-url (core.clj:53)
The encoding problem and this version incompatibility problem should not be related. Nothing encoding related has changed between Clojure 1.2 and 1.3, as far as I know. I decided to reply with my answer (even though your problem is apparently fixed), because I had already begun writing it and this is a problem many people have. (So hopefully this could be useful for someone else too.) 2011/8/17 cran1988 <rmanolis1...@hotmail.com>: > I tried (str "Γεια!") > and i got "����!" > what can I do to fix it ? Clojure has a modern string model in which a string is a logical sequence of characters, not bytes. However, Clojure cannot fix problems outside the Clojure process, so you can still get problems like this. Track A - You are running the Clojure REPL in a terminal window Before you check for any Clojure-related issues, let's make sure it's not caused by the terminal or your OS. Make sure that your locale is set to one with the UTF-8 encoding scheme (in most modern OSes this should be the case). In Unix-like systems, you can check it like this: raek@sirius:~$ echo $LANG sv_SE.utf8 Here sv_SE means Swedish, but it's the part after the dot that's interesting. After this, make sure the encoding in your terminal is set to UTF-8 too. In gnome-terminal (default terminal application in Ubuntu) make sure that "Unicode (UTF-8)" is selected in the Terminal -> Set Character Encoding menu. This should hopefully already be UTF-8 in most modern OSes. In PuTTY (a common terminal application on Windows) go to the Window -> Translation tree item and select UTF-8 in the topmost drop down list. UTF-8 is *not* the default encoding scheme in PuTTY, - ISO 8859-1 is. Now when you have a confirmed UTF-8 terminal, let's look at the Clojure side. If you use JLine or use the default installation of Leiningen (which uses JLine), you should abandon it. JLine does not support modern encoding schemes like UTF-8 and garbles the data without warnings. Use the rlwrap application instead. It does the same thing but works for encodings like UTF-8. If you install it using your OS package manager (e.g. apt-get on Ubuntu), Leiningen will pick it up and use it instead of JLine automatically. At this point, using any characters in the repl should just work. There can be subtle problems with encodings if you happen to configure things badly for both the input and output of the REPL - you can have a problem that undoes itself. To verify that the text the Clojure REPL receives is really the one you wrote, you can use this simple test: user=> (seq "Γεια") (\Γ \ε \ι \α) I.e. you give Clojure a string and ask it to display its individual characters. If you see a sequence of four characters here (and they display correctly), everything is good. If you see another number of characters something is still wrong. Track B - You are using the Slime REPL in Emacs If you recent versions of clojure-mode use the clojure-jack-in way of doing things, this should just work. Oherwise you just need to set a variable: M-x customize-variable <RET> slime-net-coding-system (select "utf-8-unix" and save) Or you can add this to your config: (setq slime-net-coding-system 'utf-8-unix) And that should be it. Use "the seq test" above to verify. I hope this helps! Please tell me if any step is not working. the "Encoding Guy" at your service, Rasmus Svensson (raek) -- 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