re: MSH: Is File/Content Binary?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



This is usually done via heuristics. For example, by checking if any character (or a certain percentage of characters) is outside of the printable range.

The printable range is usually (in hex):
- 0x0D, 0x0A (for newlines)
- 0x20 -> 0xFE (for text characters, including the extended ASCII set)

I use this approach in my format-hex script: http://www.leeholmes.com/blog/HexDumperInMonad.aspx

One point about this approach is that non-ASCII files (for example, Unicode,) appear to be binary. If that matters to you, you might go for a different heuristic, based on the percentage of characters below 0x20, for example.

--
Lee Holmes [MSFT]
Microsoft Command Shell Development
Microsoft Corporation
This posting is provided "AS IS" with no warranties, no confers rights.

-----Original Message-----
From: Keith Hill
Posted At: Saturday, December 03, 2005 11:46 AM
Posted To: microsoft.public.windows.server.scripting
Conversation: MSH: Is File/Content Binary?
Subject: MSH: Is File/Content Binary?

Is there an easy way to determine this in MSH? Many times I want to string
search files but skip binary files.

--
Keith
.



Relevant Pages

  • Re: [MSH] Problems with directory names containing square brackets
    ... This is a known issue that we have been spending time thinking about. ... characters and treat them just like any other character. ... square brackets and backticks in their name, due to msh using these ... characters as wildcard etc. ...
    (microsoft.public.windows.server.scripting)
  • Re: [MSH] MSH Not So Great For Interactive Users
    ... be at least as good as csh/tcsh at reducing the number of characters I have to type (I recognize and agree that these shells are awful for scripting). ... but the limitations of the MSH host for V1 leads partly to what you suggest. ...
    (microsoft.public.windows.server.scripting)