[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Writing bytes to stdout reverses the bytes

On Mon, Aug 20, 2018 at 11:31 AM, Grant Edwards
<grant.b.edwards at gmail.com> wrote:
> On 2018-08-20, Chris Angelico <rosuav at gmail.com> wrote:
>> On Mon, Aug 20, 2018 at 11:12 AM, Grant Edwards
>><grant.b.edwards at gmail.com> wrote:
>>> On 2018-08-20, Steven D'Aprano <steve+comp.lang.python at pearwood.info> wrote:
>>>> On Mon, 20 Aug 2018 00:31:35 +0000, Steven D'Aprano wrote:
>>>>> When I write bytes to stdout, why are they reversed?
>>>> Answer: they aren't, use hexdump -C.
>>> One might think that dumping out bytes in the correct order ought to
>>> be the default format for hexdump.  Dog only know why the actual
>>> default format was chosen.  If it was 16-bit values in _octal_ you
>>> could at least blame the PDP-11 heritage of Unix...
>> It's dumping sixteen-bit units in correct order.
> I know.  What I don't understand is is why 16-bit units in hex is the
> default.  8-bits make sense.  32-bits makes sense.  16-bits in octal
> makes sense (at least to those of us who first used Unix on a PDP-11).

Ah, I see what you mean. TBH, I no longer am surprised at weird
command defaults; many of them carry long history and sometimes
arbitrariness, maintained forever for backward compatibility. In this
specific case, I just use 'hd' instead of 'hexdump' - the defaults are
more to my liking, and it's shorter to boot.