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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---