Ok great, thanks guys.  Exactly what I needed.

On Apr 30, 12:12 am, Alex Osborne <a...@meshy.org> wrote:
> Hi Matt,
>
> Matt Culbreth <mattculbr...@gmail.com> writes:
> > I'm using slurp to read data from a file and send it to a stream, but
> > sometimes that's failing.  I've got a theory that it has to do with
> > slurp not reading binary data correctly.  Is that true?  Do I need to
> > go down to the lower level Java classes and build a byte array using
> > InputFileStream and .read()?
>
> Yep, you're spot on.  The problem is that slurp reads data as
> characters, not bytes, so they'll likely be interpreted as UTF-8
> (depends on your locale settings unless you set it explicitly) which
> will mess them up if they're not actually UTF-8 characters.
>
> You should indeed use byte arrays or DataInputStream or ByteBuffer or
> similar (depending on what sort of manipulation you need to do) rather
> than strings when working with non-textual data.  Note that
> c.c.duck-streams (now known as c.c.io) 'copy multimethod when given
> streams or byte arrays (not reader, writers or strings) will do the
> right thing.
>
> --
> 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
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group 
> athttp://groups.google.com/group/clojure?hl=en

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
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