re: MSH: Is File/Content Binary?
- From: lee.holmes@xxxxxxxxxxxxxxxxxxxx
- Date: 5 Dec 2005 09:02:33 -0800
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
.
- Follow-Ups:
- Monad Interpreter
- From: anonymous
- Monad Interpreter
- References:
- MSH: Is File/Content Binary?
- From: Keith Hill
- MSH: Is File/Content Binary?
- Prev by Date: Re: Re: is it possible to run Win32 API functions from MSH?
- Next by Date: [msh] here-strings delayed expansion
- Previous by thread: Re: Is File/Content Binary?
- Next by thread: Monad Interpreter
- Index(es):
Relevant Pages
|