# binary(2m)

[Home] [Commands] [Variables] [Macro-Dev] [Glossary]

## NAME

binary - Binary editor mode

## SYNOPSIS

binary Mode

b - mode line letter.

## DESCRIPTION

binary mode is enabled when a file is edited in binary mode. The mode is automatically enabled when a file is loaded as a binary file via find-bfile(3).

When a file is loaded using binary mode, every 16 bytes is converted into a line of text giving the hex address of the current position in the file, the bytes as hexadecimal numbers and all printable characters at the end of the line (all non-printable characters are displayed as a '`.`'). However, This format makes it memory hungry in that every 16 bytes of the file requires a 78 character line (approximately 5 times more memory!). For a more memory efficient binary mode see rbin(2m).

When writing out a file which has binary mode enabled the format of each line must have the binary mode format which is as follows:

    <address>: XX XX XX XX XX .... XX XX | <text-form>

Only the hex values (the `XX`'s) between the starting ':' marker and the terminating '|' character are used, the <address> and <text-form> are ignored.

## EXAMPLE

Given a single line MSDOS file:-

    Live long and prosper.

When loaded in using binary mode the following 2 line buffer will be produced:-

    00000000: 4C 69 76 65 20 6C 6F 6E 67 20 61 6E 64 20 70 72  |  Live long and pr
    00000010: 6F 73 70 65 72 2E 0D 0A 1A                       |  osper....

Note the "`0D 0A 1A`" at the end, this is due to MSDOS's "`\n\r`" carriage returns and `^Z` file termination, these characters are unprintable and are shown as '`.`' at the end of the line.

When saving a binary file, only the text between the '`:`' and '`|`' is considered and it may contain any number of hexadecimal numbers. The given file could be made UNIX compatible by editing the buffer to:-

    00000000: 4C 69 76 65 20 6C 6F 6E 67 20 61 6E 64 20 70 72  |  Live long and pr
    00000010: 6F 73 70 65 72 2E 0D                       |  osper....

If the word "long" is required to be removed, the following would not work:-

    00000000: 4C 69 76 65 20 6C 6F 6E 67 20 61 6E 64 20 70 72  |  Live and pr
    00000010: 6F 73 70 65 72 2E 0D 0A 1A                       |  osper....

The ASCII end letters are ignored, instead the following operation must be performed which removes the characters from the binary representation:-

    00000000: 4C 69 76 65 20 61 6E 64 20 70 72  |  Live long and pr
    00000010: 6F 73 70 65 72 2E 0D 0A 1A                       |  osper....

One could be nasty by doing the following:-

    00000000: 4C 69 76 65 20 73 68 6F 72 74 20 61 6E 64 20 |
    00000010: 64 6F 6E 27 74 20 70 72 6F 73 70 65 72 2E 0D 0A 1A           |

("Live short and don't prosper").

## NOTES

rbin and binary modes are mutually exclusive, i.e. they cannot both be enabled at the same time.

## SEE ALSO

Operating Modes, find-bfile(3), find-file(2), rbin(2m).

(c) Copyright JASSPA 2009
Last Modified: 2009/08/29
Generated On: 2009/10/12

</HMTL>