1) What encoding should clojure use to read/write to *in*, *out*, and *err*?
2) What encoding should clojure's use to load .clj files.
For 1) Clojure currently uses UTF-8 - this is hardcoded in the constants for those vars in RT.java.
I suppose there is no guarantee what encoding stdout is expecting, but the platform default encoding seems
a better bet. It might not always be correct - eg people might pipe the output of a Clojure script to a
file, or they might be using a console that uses a non-default encoding.
I notice that some tools, eg cmd.exe, allow the caller to specify the encoding of stdin/out via a command-
line flag.
In Clojure, I suppose, if an application really does want to write unicode to stdout, then it is just a
matter of rebinding *out* first to wrap System.out with a reader with the prefered encoding.
For 2) I think that it is good for Clojure to pick a fixed encoding for loading clojure files. It is much
nicer to create portable code, rather than have .clj files that fail to load on a server because the
server happens to have a different platform default encoding.
So, I'd like to see the constants in RT.java changed to not specify UTF-8, but for the encoding used by
the compiler to continue to specify UTF-8.
Anyone have any opinions?
--
Dave
> So, I'd like to see the constants in RT.java changed to not specify
> UTF-8, but for the encoding used by
> the compiler to continue to specify UTF-8.
>
> Anyone have any opinions?
I think your explanation, reasoning, and conclusions are all exactly
correct and Clojure should change as you described.
--Steve
> Ok - patch welcome ASAP (not singling out you Laurent :)
I've entered an issue and provided a patch:
http://code.google.com/p/clojure/issues/detail?id=112
Thanks,
--Steve