Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Distinguishing text from binary data

by dave_the_m (Parson)
on Oct 05, 2004 at 09:26 UTC ( #396530=note: print w/ replies, xml ) Need Help??


in reply to Distinguishing text from binary data

Of course, if the text is still in a file, you can just do -T $filename

Dave.


Comment on Re: Distinguishing text from binary data
Download Code
Re^2: Distinguishing text from binary data
by Anonymous Monk on Oct 05, 2004 at 09:49 UTC
    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...
      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.

      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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://396530]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2015-07-06 23:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (85 votes), past polls