知道什么是Big Endian,Little Endian吗?名字怪怪的,中文一般称为“大端”和“小端”。"Endian" 这个词出自乔纳森·斯威夫特的《格列佛游记》。小人国的内战就源于吃鸡蛋时是究竟从大头(Big-Endian)敲开还是从小头(Little-Endian)敲开,由此曾发生过六次叛乱,其中一个皇帝送了命,另一个丢了王位。哦嗬,相当血腥。
但是到了计算机领域,这两个词仅仅用于表示CPU处理多字节的两种不同方式。先来段权威的描述:[from Computer System: A programmer's Perspective 2.1]
For ordering the bytes representing an object, there are two common conventions. Consider a w-bit integer having a bit representation [xw-1; xw-2; : : : ; x1; x0], where xw-1 is the most significant bit, and x0 is the least. Assuming w is a multiple of eight, these bits can be grouped as bytes, with the most significant byte having bits [xw-1; xw-2; : : : ; xw-8], the least significant byte having bits [x7; x6; : : : ; x0], and the other bytes having bits from the middle. Some machines choose to store the object in memory ordered from least significant byte to most, while other machines store them from most to least. The former convention—where the least significant byte comes first—is referred to as little endian. This convention is followed by most machines from the former Digital Equipment Corporation (now part of Compaq Corporation), as well as by Intel. The latter convention—where the most significant byte comes first—is referred to as big endian. This convention is followed by most machines from IBM, Motorola, and Sun Microsystems. Note that we said “most.” The conventions do not split precisely along corporate boundaries. For example, personal computers manufactured by IBM use Intel-compatible processors and hence are little endian. Many microprocessor chips, including Alpha and the PowerPC by Motorola can be run in either mode, with the byte ordering convention determined when the chip is powered up.
举个例子吧,“汉”字的Unicode编码是6C49。那么存储这两个字节时,究竟是将6C放在前面,还是将49放在前面?如果将6C放在前面,就是big endian。还是将49放在前面,就是little endian。
网络中传输的数据都是以Big Endian的方式进行处理的,因此,如果我们的数据存放在little endian的机器上而要进行网络传输的话,我们必须进行相应的字节序转换。
分享到:
相关推荐
Big Endian & Little Endian.pdf Big Endian & Little Endian.pdf
nohead data big endian to little endian
little endian和big endian的概念解释
对于大于十进制255(16进制0xff)的整数,需要多个存储单元。例如,4660对应于0x1234,需要两个字节。不同的计算机系统使用不同的方法保存这两个字节。...前一种就被称为Little Endian,后一种就是Big Endian。
比较详细的介绍了大小端问题。嵌入式系统开发者应该对Little-endian和Big-endian模式非常了解。
this pdf is for big endian little endian concept useful for application devloper
little endian,big endian 小端存储、大端存储.zip
大端(Big Endian)与小端(Little Endian)简介
大端(Big_Endian)与小端(Little_Endian)简介
php 字符编码转换类,支持ANSI、Unicode、Unicode big endian、UTF-8、UTF-8+Bom 互相转换。
基于STM32HAL库,USART-调试串口(大小端测试),对应文章:https://blog.csdn.net/qq_36075612/article/details/115935138?spm=1001.2014.3001.5501
你是否遇到过,内存中的数据顺序颠倒 你存入1234,实际存储的是3412. 字节存储顺序: little-endian小端,big-endian大端 教程 主机序,网络序 hton,ntoh
VC ANSI环境下按行读取ANSI、UNICODE 、UNICODE big endian、UTF-8四种文本文件.docx
用于测试您所用的PC机的数据存储模式是大端还是小端
(包括ANSI、UNICODE、UNICODE big endian、UTF-8)格式的文本文件 */ //核心算法:CStdioFileEx继承自CStdioFile, 覆盖CStdioFile的 BOOL ReadString(CString& rString)方法, // 根据不同文件编码特征,寻找文件...
文本字符串编码在 Text、ANSI、Unicode、Unicode Big Endian、UTF-8、 UTF-7 之间的互相转换,转换结果使用十六进制表示。
读取ANSI 明码文件 读取Unicode 明码文件 读取Unicode big endian 明码文件 读取UTF-8 明码文件 读取UTF8 Bom 明码文件 读取UTF16-LE 明码文件 读取UTF16-BE 明码文件 到多字节字符串 扩展类CFilePlainCode
如何提取大端存储(Big-Endian)二进制文件中的数据,并输出到txt中。matlab实现
buffer ) ) [ 0 ] === 0x04030201 )用法使用 npm 安装: npm install is-little-endian然后像这样使用它: if ( require ( "is-little-endian" ) ) { // Use little endian buffer} else { // Use big endian ...
探寻big endian little endian 的最原始文章,熟悉字节存储机制不可或缺的资料~~