Hi,
I am currently working on an application that extracts info from specific kinds of Binary files (which are encoded LittleEndian).
I have got Ints out of the Data fine - using CFSwapInt32LittleToHost or CFSwapInt16LittleToHost
However I am having problems extracting a String.
I know the offset into the data where the string is, and the length of the string:
Code:
nameData = [symbianFileData subdataWithRange: NSMakeRange( componentNameOffset , componentNameSize) ];
NSLog(@"nameData: %@", nameData);
gives:
Code:
nameData: <4f007000 65007200 6100>
(notice the alternating 00s)
When I try to convert that data into a string however, I get a string separated by spaces:
Code:
componentName = [[NSString alloc] initWithData: nameData encoding: NSNonLossyASCIIStringEncoding ];
gives:
Code:
componentName: O\\000p\\000e\\000r\\000a\\000
I've tried various NSStringEncodings - but they all end up the same (with the Spaces (\\000) between each character.)
Is this something to do with the fact that the original data is Little-Endian?
Do I need to do some kind of byteSwapping on the Data?
Thanks,
Diggory