7

Although I set UTF-8 everywhere (in my lein project, the slime-lisp group customization, the Emacs buffer itself...), I keep getting this error when trying to run code such as (def beta "β"):

Coding system iso-latin-1-unix not suitable [...]

Happens only in Emacs, not when running lein repl from the command line, for instance.

What could be causing it? I'm using Ubuntu, if that makes any difference.

Mirzhan Irkegulov
  • 17,660
  • 12
  • 105
  • 166
deprecated
  • 5,142
  • 3
  • 41
  • 62
  • by the way... Does *.clj* file have a character encoding specified that every *.clj* file have to use? For example Google's Go language specs says that every source code file *must* be UTF-8 while Java doesn't specify anything (you can use UTF-8 or ISO-8859-1 or what you want for *.java* source code files). What about *.clj* file? – TacticalCoder Apr 16 '12 at 02:24
  • The built-in `load-file` fn slurps anything so I don't think so... – deprecated Apr 16 '12 at 04:40
  • 1
    All .clj files must be in UTF-8. This isn't documented anywhere (unfortunately), but it is hard-coded into the compiler: https://github.com/clojure/clojure/blob/3297866c23dd01a5b0db14ed836336d128972aac/src/jvm/clojure/lang/Compiler.java#L6912 – raek Apr 16 '12 at 17:56
  • @vemv: SLIME's default settings assumes Common Lisp, which has a different tradition of default encoding. If you use clojure-jack-in, it will automatically set the encoding to to utf-8-unix (since it knows you are using Clojure), but if you use "vanilla SLIME" you have to configure this yourself. – raek Apr 16 '12 at 18:00
  • raek: cool, nice find! I don't use `clojure-jack-in` but plain `slime-connect` instead. this has the advantage of not creating a swank process each time. so I launch just one swank instance at OS startup, so connections take nothing rather than ~10 seconds (on my machine). – deprecated Apr 16 '12 at 19:07

1 Answers1

6

you should have following code in your .emacs:

(setq slime-net-coding-system 'utf-8-unix)

and following in your project.clj when you run lein swank (or setup swank.encoding Java system property to utf-8):

:encoding "utf-8"
Alex Ott
  • 80,552
  • 8
  • 87
  • 132
  • `:encoding "utf-8"` made the difference for me; I was using `:jvm-opts ["-Dfile.encoding=utf-8"]` instead. Thank you! – deprecated Apr 16 '12 at 07:34