NSDATA data protocol defines a data length of 4 is the length of a file, the data type of a given proposal int32, (bottom first) I want the length of the data is converted to an int 4 value to ask how to convert . Such data (bd, 3c, 0,0) NSDATA convert the hexadecimal value after
Reply:
The size of bytes of the points, the big end of the byte is the first bit, byte is a small bit at the end.
You can define a union
{
int32 k;
char c [4];
}
union.k = length
Then according to union.c [x] can be directly taken to the first of several
Reply:
Thank you to approach this issue is resolved so that someone sent to detours
# Pragma mark Byte4 turn int16 bit first high end after
- (Int) bytes2ToINT16: (Byte [4]) val
{
int return_val = val [0] &0xFF;
return_val | = ((val [1] << 8) & 0xFF00);
return return_val;
}
# Pragma mark Byte4 turn int32 bit first high end after
- (Int) bytes4ToINT32: (Byte [4]) val
{
int num = val [0] & 0xFF;
num | = ((val [1] << 8) & 0xFF00);
num | = ((val [2] << 16) & 0xFF0000);
return num;
}
No comments:
Post a Comment