开发者

Is it true that endianness only affects the memory layout of numbers,but not string?

Is it true开发者_JS百科 that whether the architecture is big or little endian ,only the memory layout of numbers differ,that of the string is the same.


If you have a simple 8-bit character representation (e.g. extended ASCII), then no, endianness does not affect the layout, because each character is one byte.

If you have a multi-byte representation, such as UTF-16, then yes, endianness is still important (see e.g. http://en.wikipedia.org/wiki/UTF-16#Byte_order_encoding_schemes).


For strings of 1-byte characters that is correct. For unicode strings (2 bytes/character) there will be a difference.


That's generally not true. Depending on the circumstances, more than one byte might be used for characters, in which case there is a difference between little endian encoding of characters and big endian encoding of characters.


For the most part, but you should understand why. Big vs little endian refers to the ordering of bytes in multi-byte data types like integers. ASCII characters are just a single byte.

Note however that unicode characters are multiple bytes, so the byte order matters. The entire point of unicode is that the single byte in ASCII can only encode 256 different values, which is not enough for all the languages in the world.

Refer here for more informantion about what endianness means: http://www.cs.umd.edu/class/sum2003/cmsc311/Notes/Data/endian.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜