in reply to Re: Distinguishing text from binary data
in thread Distinguishing text from binary data

No it isn't a file - it's a body of an HTTP response. I suppose I can write it to a file, although it does seem like a waste...
  • Comment on Re^2: Distinguishing text from binary data

Replies are listed 'Best First'.
Re^3: Distinguishing text from binary data
by dave_the_m (Monsignor) on Oct 05, 2004 at 10:17 UTC
    No it isn't a file - it's a body of an HTTP response
    In that case, is examining the Content-type: header in the response sufficient?

    Dave.

      I'd tend to agree that the simplest course would probably be to check the headers that came with the data - they should give you the content-type as well as the encoding without you having to make assumptions about what makes the code binary or otherwise.

      --- Jay

      All code is untested unless otherwise stated.

Re^3: Distinguishing text from binary data
by nothingmuch (Priest) on Oct 06, 2004 at 00:21 UTC
    Those tests work on filehandles too, so if you have a socket, that should work.

    perldoc -f -X says it reads the current buffer for FHs, and the first block for files.

    -nuffin
    zz zZ Z Z #!perl