Reputation: 2731
I am confused about QByteArray data. Can someone please explain the below scenario for me.
Here data type for each array index is char. I understand some of those values. Like 74 'J'
I understand the first one is ASCII and second one is the corresponding character. But what is the meaning of -1 '\\377'
Also what does the below gui means?? I sent the QByteArray of above to a function which takes the QByteArray as unsigned char* source
. The below gui is showing the value of that source
.
The main confusing part is the first line's value 0x87089e8 "\377\330\377\340"
Upvotes: 1
Views: 1184
Reputation: 3566
I'm answering about the meaning of 0x87089e8 "\377\330\377\340"
.
0x87089e8
is the value of the source
pointer, i.e. it's an address
in memory. "\377\330\377\340"
is the character string stored at that
address, written as octal escape sequences. It's written this way
because none of these characters is ASCII (ASCII goes only from 0 to
127). In hex, the string of bytes is ff d8 ff e0 00
. The 00
at the end
is interpreted as and end-of-string mark (ASCII NULL).
Upvotes: 2
Reputation: 137497
char
in C/C++ is a signed 1-byte integer. This GUI is simply expressing that value as a signed decimal number, and the equivalent ASCII character.
You're asking about the byte value -1, which can be interpretted in the following ways:
Binary 11111111
Octal 0377
Hex 0xFF
Decimal -1 (Signed)
255 (Unsigned)
ASCII \377
\xFF
Note that there isn't a standard printable ASCII character for 255, which is why they show it like they do.
Another Example:
Binary 01001010
Octal 0112
Hex 0x4A
Decimal 74 (Signed)
74 (Unsigned)
ASCII 'J'
Upvotes: 2