Since I can't find the way to solve this issue, let's tackle it at a more fundamental level.
First, I need to make sure I can print to standard output without using *out*, so I can later, temporarily bind *out* to something else. Also, I don't want to print directly to System/out. Later, I'll need it to be wrapped into something that gives it a proper encoding. user=> (import '(java.io PrintWriter PrintStream)) nil user=> (.print (PrintWriter. (PrintStream. System/out) true) "bonjour") nil Do you know how to make this work? Daniel Jomphe wrote: > Let's say I have this file to parse: > > <?xml version="1.0" encoding="ISO-8859-1"?> > <root>Québécois français</root> > > I spent many hours trying different ways of doing it, but still > haven't found one. Here are probably my best attempts: > > (def n "ISO-8859-1") > > (defmacro with-out-encoded [encoding & body] > `(binding [*out* (java.io.OutputStreamWriter. System/out > ~encoding)] > ~...@body)) > > (:content (clojure.xml/parse "french.xml")) > ; ["Qu√©b√©cois fran√ßais"] > > (with-out-encoded n > (:content (clojure.xml/parse "french.xml"))) > ; ["Qu√©b√©cois fran√ßais"] > > (with-out-encoded n > (let [x (org.xml.sax.InputSource. (java.io.FileInputStream. > "french.xml"))] > (do > (.setEncoding x n) > (:content (clojure.xml/parse x))))) > ; ["Qu√©b√©cois fran√ßais"] > > Some xml files appear different when I run them through these lines; > this one does not. In all cases, though, I don't get what's really > expected. > > How would go about it? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---