Difference between Big Endian and little Endian Byte order

前端 未结 6 426
情歌与酒
情歌与酒 2020-11-27 10:33

What is the difference between Big Endian and Little Endian Byte order ?

Both of these seem to be related to Unicode and UTF16. Where exactly do we use this?

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-27 11:07

    Ferdinand's answer (and others) are correct, but incomplete.

    Big Endian (BE) / Little Endian (LE) have nothing to do with UTF-16 or UTF-32. They existed way before Unicode, and affect how the bytes of numbers get stored in the computer's memory. They depend on the processor.

    If you have a number with the value 0x12345678 then in memory it will be represented as 12 34 56 78 (BE) or 78 56 34 12 (LE).

    UTF-16 and UTF-32 happen to be represented on 2 respectively 4 bytes, so the order of the bytes respects the ordering that any number follows on that platform.

提交回复
热议问题