find-bfile - Load a file as binary data
n find-bfile "file-name" (C-x 9)
find-bfile loads a file as binary, providing binary editing capabilities.
The command operates as find-file(2) except that it loads the given file with binary(2m) mode set. binary mode loads any file and converts every 16 bytes 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 '.').
The extension of a file loaded in binary mode is ignored with respect to file hooks (See add-file-hook(2)). Instead the fhook-binary command is always executed if it exists.
Each line of text may be edited, providing that the basic format of every line remains the same, the altered file may be written out, providing full binary editing capabilities. This mode has two draw-backs, firstly it is memory hungry in that every 16 byte of the file requires a 78 character line (approximately 5 times more memory!). Secondly if the binary mode is added globally then EVERY file is loaded in binary mode, including macro files which subsequently will not execute. For this reason, it is recommended that this mode is not added globally.
Example, given a single line MSDOS file:-
Live long and prosper.
When loaded in binary mode will produce the following 2 line buffer:-
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. The basic form of a binary file is:-
AAAAAAAA: XX XX XX XX .... |
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").
(c) Copyright JASSPA 1999
Last Modified: 1998/07/10
Generated On: 1999/12/01