On Sat, 2009-03-07 at 05:43 -0800, max3000 wrote:
> Ok, so I ended up doing this in my code:
> 
>       String resource = "/exmentis/rules_main.clj";
>       InputStream is = getClass().getResourceAsStream(resource);
>       String script = ... read in is as a String (like slurp) ...
>       StringReader r = new StringReader(script);
>       clojure.lang.Compiler.load(r, null, resource);
> 
> Note I use clojure.lang.Compiler directly because RT has no methods to
> do what I want.
> 
> The above works fine, and requires no modifications to the clojure
> source code.

Hi Max,

Please tell us a bit about your environment (locale settings, OS). It
looks to me like your settings are different from UTF-8 and the reason
why the above procedure works is because Java will use the default
character set when decoding your source file. Within Java (or Clojure)
you can get the default character set with:

(java.nio.charset.Charset/defaultCharset)

which in my case produces #<UTF_8 UTF-8>. If you are using a different
character set (e.g. ISO-8859-1), some characters can not be mapped
directly between this and UTF-8. While I am not aware of any explicit
requirements regarding Clojure source file encodings, it seems that de
facto UTF-8 is assumed. Try encoding your sources as UTF-8 and things
should work as expected.

Cheers,
Toralf



--~--~---------~--~----~------------~-------~--~----~
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
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