cURL / Mailing Lists / curl-users / Single Mail

curl-users

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

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

"Daniel Stenberg" <daniel_at_haxx.se> 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.?

--gv

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2014-02-26