The NSData object is shown as hexadecimal bytes. Hex 34 is equal to decimal 52. So the result is correct.
NSData.bytes giving back different byte array
-
30-07-2022 - |
Question
Basically I'm using NSData to convert my NSString to bytes or byte array.
In java "4" is represented as 52 as byte but in NSData it is 34
e.g.
NSString *sampleString = @"474";
NSData *data = [sampleString dataUsingEncoding:NSUTF16LittleEndianStringEncoding];
The produced result is
<34003700 34... >
Hence we are expecting
<52005500 52... >
Any idea why it is different from objective-c?
Thank you
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow