• About the big-endian and little-endian.

    From hongyi.zhao@gmail.com@21:1/5 to All on Tue Aug 22 06:58:31 2023
    See my following example:

    werner@X10DAi:~$ echo -n -e "\x12\x34\x56\x78" | od -An -x --endian=big
    1234 5678
    werner@X10DAi:~$ echo -n -e "\x12\x34\x56\x78" | od -An -x --endian=little
    3412 7856

    Could you tell me why the latter doesn't give the following result?

    7856 3412,
    aka,
    0x78 0x56 0x34 0x12

    Regards,
    Zhao

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to hongy...@gmail.com on Tue Aug 22 16:49:05 2023
    On 22.08.2023 15:58, hongy...@gmail.com wrote:
    See my following example:

    werner@X10DAi:~$ echo -n -e "\x12\x34\x56\x78" | od -An -x --endian=big
    1234 5678
    werner@X10DAi:~$ echo -n -e "\x12\x34\x56\x78" | od -An -x --endian=little
    3412 7856

    (My 'od' doesn't support '--endian'; I use different options below
    and show only the little-endian results.)


    Could you tell me why the latter doesn't give the following result?

    Endian-ness swaps bytes in "words" (default "word" is 2 octets; you
    define what a "word" is).

    $ echo -n -e $'\x12\x34\x56\x78' | od -An -t x1
    12 34 56 78
    $ echo -n -e $'\x12\x34\x56\x78' | od -An -t x2
    3412 7856
    $ echo -n -e $'\x12\x34\x56\x78' | od -An -t x4
    78563412
    $ echo -n -e $'\x12\x34\x56\x78\x90\xab' | od -An -t x8
    0000ab9078563412


    Janis


    7856 3412,
    aka,
    0x78 0x56 0x34 0x12

    Regards,
    Zhao


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From hongyi.zhao@gmail.com@21:1/5 to Janis Papanagnou on Tue Aug 22 17:47:24 2023
    On Tuesday, August 22, 2023 at 10:49:11 PM UTC+8, Janis Papanagnou wrote:
    On 22.08.2023 15:58, hongy...@gmail.com wrote:
    See my following example:

    werner@X10DAi:~$ echo -n -e "\x12\x34\x56\x78" | od -An -x --endian=big 1234 5678
    werner@X10DAi:~$ echo -n -e "\x12\x34\x56\x78" | od -An -x --endian=little 3412 7856
    (My 'od' doesn't support '--endian'; I use different options below
    and show only the little-endian results.)

    What's your version of 'od'? Mine is as follows:

    werner@X10DAi:~$ od --version|head -1
    od (GNU coreutils) 8.32


    Could you tell me why the latter doesn't give the following result?
    Endian-ness swaps bytes in "words" (default "word" is 2 octets; you
    define what a "word" is).

    $ echo -n -e $'\x12\x34\x56\x78' | od -An -t x1
    12 34 56 78
    $ echo -n -e $'\x12\x34\x56\x78' | od -An -t x2
    3412 7856
    $ echo -n -e $'\x12\x34\x56\x78' | od -An -t x4
    78563412
    $ echo -n -e $'\x12\x34\x56\x78\x90\xab' | od -An -t x8
    0000ab9078563412

    Got it. Thank you very much for your explanation.


    Janis

    Zhao


    7856 3412,
    aka,
    0x78 0x56 0x34 0x12

    Regards,
    Zhao


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)