Wingzero Wingzero - 4 months ago 9
Objective-C Question

LLDB po command encoding format of "\332"

So I got a NSData from backend server, my backend engineer folk says there is a simple decoding logic and I have to get the second byte.

So I have turned this NSdata into bytes array via

const unsigned char *usageBuf = (unsigned char *)[keyData bytes];


When I print it on LLDB, it outputs like:


(lldb) po usageBuf
"\x16\332d\336C\xa2Jc\x88./Q\374\326[\x01\x01\xa8\314\x96\x8d\320.c\x8bѐ\r\xb7'\317\366\342\206>\x1fE\322e\x91\311\354\302"


however when I try to print usageBuf[1], it's like:

(lldb) po usageBuf[0]
'\x16'

(lldb) po usageBuf[1]
'\xda'

(lldb) po/x usageBuf[1]
0xda

(lldb) po usageBuf[2]
'd'


I am confused how '\332' turned into '\xda'? I searched the UTF8 table, but it just says
UTF-8 0x5C 0x33 0x33 0x32
, so I must be missing some puzzles, please help, thanks!

Avi Avi
Answer

It's a matter of numerical base:

hex DA == dec 218 == oct 332