I got some weird issue here. The code is as below
NSMutableString *unicodeString = [NSMutableString string];
for (NSUInteger i = 0; i < [data length]; i++) {
unsigned char byte;
[data getBytes:&byte range:NSMakeRange(i, 1)];
unichar unicodeChar = byte;
NSString *appendString = [NSString stringWithFormat:@"%C",[_toUnicode unicharFromCIDString:unicodeChar]];
[unicodeString appendFormat:@"%@",appendString];
NSLog(@"%@",appendString); //1
}
NSLog(@"%@",unicodeString)//2
the appendString print, but unicodeString never print. Is this because of bytes issue?? I have tried retain appendString but it still won't print
*UPDATED found the answer
I have found that the problem is %C is for 16bit unichar so If I want to append to NSString I have to use %c which is 8bit. This works perfectly.