Is endian conversion required for wchar_t data?

后端 未结 2 1654
小鲜肉
小鲜肉 2020-12-18 02:59

In C/C++, if a multi-byte wide character (wchar_t) value is transmitted from a big-endian system to a little-endian system (or vice-versa), will it come out the same value o

2条回答
  •  误落风尘
    2020-12-18 03:13

    Endian conversion is not sufficient and as a consequence not needed. Sizeof(wchar_t) differs, and therefore the encoding too. Hence, you need to agree on an interchange format. The logical choice is UTF-8. But since UTF-8 is byte-oriented, you do not have endianness issues anymore.

提交回复
热议问题