I'm trying to write some XML to a file using clojure/data.xml
I have created a leiningen project (src here). The main function looks like this:
(defn -main
[]
(let [tags (element :foo {:foo-attr "foo value"}
(element :bar {:bar-attr "bar value"}
(element :baz {} "The baz value")))]
(with-open [out-file (java.io.FileWriter. "C:/Users/amyers/Desktop/output.xml")]
(emit tags out-file))))
When I run it (on Windows 7 Pro, 64bit), I am getting the following output:
C:\Users\amyers\projects\clojure-projects\data-xml>lein run
Exception in thread "main" java.lang.Exception: Output encoding of
stream (UTF-8) doesn't match declaration (Cp1252)
I am guessing that the underlying Java output stream has Cp1252 as the character encoding but it's trying to write UTF-8 (which is what I want). How can I write the XML successfully in UTF-8 please?
No comments:
Post a Comment