Why UTF-32 exists whereas only 21 bits are necessary to encode every character?

前端 未结 5 1663
既然无缘
既然无缘 2020-12-05 07:02

We know that codepoints can be in this interval 0..10FFFF which is less than 2^21. Then why do we need UTF-32 when all codepoints can be represented by 3 bytes? UTF-24 shoul

5条回答
  •  情歌与酒
    2020-12-05 07:27

    It's true that only 21 bits are required (reference), but modern computers are good at moving 32-bit units of things around and generally interacting with them. I don't think I've ever used a programming language that had a 24-bit integer or character type, nor a platform where that was a multiple of the processor's word size (not since I last used an 8-bit computer; UTF-24 would be reasonable on an 8-bit machine), though naturally there have been some.

提交回复
热议问题