All files are binary.
I'll try to explain.
What is generally referred to as a text file is one in which (8 bits = 1 ASCII character) the 8th bit of each byte is not used.
The data that can be stored in 7 bits of a 'text' file is ASCII (printable) data, it is still binary, and even though only 7 bits are used, it will occupy 8 bits of space.
7 bits can hold 2^7 different or 128 different values (base 10 or decimal), enough to hold the basic character set, UTF-8 (UTS Transformation format) fits is 8 bits and is used for backwards compatibility with ASCII. UTF-16 takes two bytes per character and is still considered a 'text' format. UTF-32 4 bytes, still text.
A binary file though is a sequence of bytes, it can contain information in any base, so will take as many bits as necessary for the base in question. Packed data can cross byte boundaries and can contain even or odd number of bits for a single data item. The next data item will start on the next bit (but doesn't have to) case in point is phone call records which are a stream of bits. Some bits will sometimes be skipped for alignment sometimes not. The structure of a chunk (record) of data is what makes sense of it all.
Take for example:
1 2 3 4 5
|
struct example {
int y;
unsigned char x;
char z;
}l
|
if this data were to be written to a file, y would take 4 bytes, x one byte (7 bits used, 8th bit ignored) and z 1 byte (8 bits used) the entire structure would occupy 6 bytes.
There's a lot more to it (BCD for one which is binary coded decimal, which can hold a two digit number in 2 'nibbles' of 1 byte) but hope this helps some.
Largins