hasci - view a file interactively in hexadecimal and ASCII

Synopsis

hasci [options] [file name]
hasci --help
hasci --version

Description

hasci is a utility for looking at the structure of binary files. It displays each byte of a file as a hexadecimal (base 16) code and as an ASCII character.

There are many existing hex file viewers, but hasci has two advantages over most of them:

  • It uses color coding to distinguish printable ASCII characters, control characters and non-ASCII characters.

  • It doesn't try to read the whole file into memory, allowing very large files to be displayed.

Having said that, this is only the first version of hasci, and there are many things missing, not least of which is the ability to edit the files being displayed.

To use hasci run it with the name of a file. The file can then be navigated with the keyboard. Pressing E will show a summary of the commands available, and they are explained in more detail below.

By default hasci color's characters (both the hexadecimal and ASCII representations) according to their character code. Printable ASCII characters are shown in white, control characters in red and characters with codes above 126 (i.e. the ASCII delete character and all characters outside the normal ASCII range) in green. This color coding can be turned off by pressing C.

Characters that might not be printable on a terminal are displayed as . in the ASCII part of the display. Characters with codes above 126 can be shown by pressing 8. When color coding is turned on hasci will display some control codes as letters. This will not happen when coloring is turned off, because then the control codes would be indistinguishable from plain letters in the ASCII display. This feature can be adjusted with the O command. The letters used for control codes are shown here (those not listed are shown as .):

0   null (0x00),
a   bell/alert (0x07),
b   backspace (0x08),
t   tab (0x09),
n   line feed/newline (0x0A),
v   vertical tab (0x0B),
f   form feed (0x0C),
r   carriage return (0x0D), and
e   escape (0x1B).

Each line of the display in hasci begins with the offset (in hexadecimal) of that line from the start of the file being viewed. The offset of the cursor is also shown at the bottom of the screen.

Options

-H, --help

Give a brief description of what hasci does.

-V, --version

Print the name and version number of the program.

Keyboard Commands

8

Toggle whether characters with codes above 126 should be shown in the ASCII section of the display. The default is off. When turned off these characters are represented by a ..

B or the Page Up key

Move the cursor up by a screenful of data.

C

Toggle color coding of characters. The default is on.

D

Change the type of line indicators used to mark the current line. The default is to use arrows and dashes, but there are two other choices.

E

Print a summary of the available commands.

H or left arrow

Move the cursor left.

J or down arrow

Move the cursor down.

K or up arrow

Move the cursor up.

L or right arrow

Move the cursor right.

M or the Home key

Move the cursor to the start of the current line.

N or the Page Down key

Move the cursor down by a screenful of data.

O

Toggle the use of letters for some control codes (as described above) in the ASCII section of the display. The default is on, but it is only used when color coding is also turned on.

Q

Quit.

, or the End key

Move the cursor to the end of the current line.

Bugs

There are many features missing, including an optional GUI interface, editing facilities and the ability to mark and save chunks of data to other files. The next version of hasci is underway, and it will be a complete redesign, rewritten from scratch. It should have some funky new features, but I can't say exactly what yet. See the file TODO.

The keyboard handling is rubbish. It doesn't work on an xterm and probably won't work properly on most systems.

The screen doesn't clear properly on an xterm when quitting.

Copying

Copyright 1999 Geoff Richards

Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.

Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.

Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that this permission notice may be included in translations approved by the Free Software Foundation instead of in the original English.

Author

Geoff Richards <geoff@laxan.com>

http://ungwe.org/free_software/hasci/

See Also

hasc(1), the predecessor of hasci, which outputs a hex and ASCII representation of a file, with optional color coding, but as a filter rather than an interactive program.