Working with files › From the window to the file · 8 min read
Underneath, every file is the same thing: zeros and ones. What changes is what those zeros and ones represent.
In a text file, each little group of bits represents a character: a letter, a number, a space, a line break. And because everyone agreed decades ago on which number belongs to which letter, any program can read it without knowing anything about the other.
TEXT — .md .csv .html .svg
Change line 3. The other six stay untouched.
BINARY — .pdf .docx .png
%PDF-1.7 %âãÏÓ 4 0 obj <</Filter/FlateDecode/Le ngth 3721>> stream xœÝ] Ë'ãÆ'Ýç+ ¦'&†½Ø€ û¢‡ $Á>zÐ ‰Ì4ÅêGwSj4? ~
There is no "line 3". The whole file is regenerated.
In a binary file the bits mean something else: the color of a pixel, the length of a compressed block, which byte page 4 starts at. Only the program that wrote it knows what each one means.
No letters, no lines. Just a block.
The kitchen test: open it with Notepad. If you can read it, it is text. If you see a mess of symbols, those are bits that are not letters, and Notepad is showing them to you as if they were.
Why can you edit a single line of a text file but not of a PDF?
The difference is what you can point at.
snack 4 of 9 · From bits to letters
Powered by KlugerByte