C++ Logo

std-discussion

Advanced search

Re: What even happened to <net> and byte swapping?

From: Thiago Macieira <thiago_at_[hidden]>
Date: Thu, 25 Feb 2021 11:43:49 -0800
On Thursday, 25 February 2021 07:02:18 PST Matthew Woehlke via Std-Discussion
wrote:
> On 24/02/2021 11.12, Gennaro Prota wrote:
> > I have worked on many applications that needed to handle different
> > endiannesses, but never had to swap bytes around, either in C++ or in
> > C#.
>
> So, let's say you have an image file that is big-endian encoded on a
> little-endian system. You need to know the dimensions. How do you get
> those as numbers the CPU can actually use? Do you just read everything a
> byte at a time?

The way I read Gennaro's answer is that "byte swapping" is not the operation
most people want. Dealing with endianness is. One doesn't want to have to care
about whether they need to swap or not.

For that reason, I don't think P1272 is the right answer.

What we need is the four functions in the matrix:
        big_endian little_endian
to X X
from X X

Like I did for Qt: https://doc.qt.io/qt-6/qtendian.html#functions

PS: looks like the documentation for the overloads for memory regions is
missing.
-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DPG Cloud Engineering

Received on 2021-02-25 13:43:54