isBinary binary file discriminator

Given a filename, returns 1 if the file is binary, 0 if text. A pastiche of the work of many, culled from a thread in comp.lang.tcl

 proc isBinary { filename } {
     if { [ catch {
        set bin_rx {[\x00-\x08\x0b\x0e-\x1f]}
        set fid [ ::open $filename r ]
        fconfigure $fid -translation binary
        fconfigure $fid -buffersize 1024
        fconfigure $fid -buffering full
        set test [ read $fid 1024 ]
        ::close $fid
        if { [ regexp $bin_rx $test ] } {
           set bool 1
        } else {
           set bool 0
        }
     } err ] } {
        catch { ::close $fid }
        return -code error "isBinary: $err"
     }
     return $bool
 }