binGetString

Get textual part of binary data

Summary
binGetStringGet textual part of binary data
LicenseNew BSD License
IntroductionI tried to make a function to read textual portion of binary files.
binGetStringGet ASCII printable characters portion of the binary data.

License

New BSD License

Copyright © 2006, 2007, 2009, 2010, Tuncay All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of the Tuncay nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL Tuncay BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Introduction

I tried to make a function to read textual portion of binary files.  After searching the forum, I did not find any solution (that day).  The function can be used to read out headers etc.

Links

Date

2010-09-29

Revision

2.0

Developers

  • Tuncay (Author)

Category

String Manipulation, FileSystem

Type

Library

Standalone (such as no need for extern file or library)

Yes

StdLibConform (such as use of prefix and no globals use)

Yes

binGetString

binGetString(ByRef _data,  
 _size =  "",
 _offset =  0,
 _file =  "")

Get ASCII printable characters portion of the binary data.

Parameters

dataReference to variable with the binary data.
sizeIf no file is to load, then this is the final size of string to get.  Otherwise it is the size of file to load.  Leave blank value “” to get all.
offsetHow many data (characters) to leave out from begin of data.  Defaults to “0”.
filePath to a file to load and overwrite to data variable.

Return

All characters in string (or file) within range lower than 127 and higher than 31 (compared as decimal ascii values).

ErrorLevel

Without a filepath at file parameter, ErrorLevel is unchanged.  But if a filepath is specified, then ErrorLevel reflects same ErrorLevel as the AutoHotkey builtin command FileRead.  “0” for success, otherwise non zero.

Example

MsgBox % str := binGetString(bindata, 800, 64, filename)
binGetString(ByRef _data,  
 _size =  "",
 _offset =  0,
 _file =  "")
Get ASCII printable characters portion of the binary data.
Close