cURL / Mailing Lists / curl-users / Single Mail


Re: Prevent/confirm before dumping binary data to terminal?

From: Gisle Vanem <>
Date: Wed, 26 Feb 2014 10:48:03 +0100

"Daniel Stenberg" <> wrote:

> No, I've not seen anyone suggest such an idea but I have to admit it sounds
> rather attractive. Do you have any particular insights in how less or other
> tools do the detection?

It opens and reads at most 256 bytes in a file. It's a binary file if there are
more than 5 "binary" characters in the buffer. A binary character is checked
using a lookup table depending on the UTF-8 mode. Hence, less is handling a
file as a *text* if it has verified it's a UTF-8 file (and UTF-8 mode is active).

So the check for a true binary file gets a bit complicated. And what about UTF-16
(little or big endian), BOM etc.?


List admin:
Received on 2014-02-26