HP OpenVMS Systems

ask the wizard
Content starts here

Determining if file is printable or binary?

» close window

The Question is:

Is there a way to determine if a file is in a "readable" format? In other
 words, not an image or executable, but in a text file format (source code, txt
 files, etc...) ?

The Answer is :

  Not with any particular certainty, in the general case.
  Various examinations could be used to approximate the decision whether
  (or not) a file is printable.  Obvious considerations include the RMS
  record structure, the character set used within the records, and the
  filename extension, but this approach is clearly an imperfect and even
  moderately complex proposition, and one that will not be entirely
  There are certainly cases where various attributes will indicate it is
  very unlikely that the contents of a particular file are printable.
  For example, files with obvious binary charactersets, invalid embedded
  ANSI escape sequences, and file extensions such as .EXE would all
  tend to indicate that the file is not printable.
  Accordingly, it would be easier to decide which files are likely not
  printable than to decide which are.

answer written or last revised on ( 10-DEC-2002 )

» close window