Sorry for all these posts.

I pasted my last post's code into a fresh repl (not in my IDE), and
here's what I got (cleaned up):

  #'user/s
  québécois françaisnil
  qu?b?cois fran?aisnil

  #'user/snc
  québécois françaisnil
  qu?b?cois fran?aisnil

I'm not sure what to make out of it.

My terminal (Apple Terminal) supports the encoding, and prints
correctly s and snc out of the box.
When I use with-out-encoded, I actually screw up both s and snc's
printing.


Daniel Jomphe wrote:
> Now that I know for sure how to bind *out* to something else over
> System/out, it's time to bring back my encoding issues into scope:
>
>   (import '(java.io PrintWriter PrintStream))
>
>   (defmacro with-out-encoded
>     [encoding & body]
>     `(binding [*out* (java.io.PrintWriter. (java.io.PrintStream.
> System/out true ~encoding) true)]
>               ~...@body
>               (flush)))
>
>   (def nc "ISO-8859-1")
>
>   ;;; with a normal string
>   (def s "québécois français")
>
>   (print s)
>   ; quÔøΩbÔøΩcois franÔøΩaisnil
>
>   (with-out-encoded nc (print s))
>   ; qu?b?cois fran?aisnil
>
>   ;;; with a correctly-encoded string
>   (def snc (String. (.getBytes s nc) nc))
>
>   (print snc)
>   ; qu?b?cois fran?aisnil
>
>   (with-out-encoded nc (print snc))
>   ; qu?b?cois fran?aisnil
>
> I'm certainly missing something fundamental somewhere.
--~--~---------~--~----~------------~-------~--~----~
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