4 ms·
> what if your output is a normal UTF-8 string but contains a byte 0? It's not really a valid character to print to a terminal and most terminals ignore it nor
by asdfaoeu 9y ago
> what if your output is a normal UTF-8 string but contains a byte 0?
It's not really a valid character to print to a terminal and most terminals ignore it nor is it particular valid in a "text file".
As for the rest of your questions if the bytes in the file are randomly distributed which is common with compressed binary files the chance that there is not a zero byte in the first 2000 bytes is 0.03% which seems low enough.
- baby 9y ago> if the bytes in the file are randomly distributed This is rarely true I believe, but binary files should often use the 0 byte because it sounds "practical" to use (going with the instinct here). So I'm guessing this test is "good enough"