resData
does NOT contain ASCII characters, because ASCII does not include characters for å, ä, and ö. If resData
is a UTF-8 encoded string, then some characters (including these) are encoded using more than one byte.
It looks like you want a way to print the *n*th character. First, do as @Jack said and turn those bytes into an NSString
:
/* Assuming |resData| is NULL-terminated and UTF-8 encoded... */
NSString *text = [NSString stringWithUTF8String:resData];
Now, to print the *n*th character of text
:
NSUInteger n = 3;
NSString *character = [text substringWithRange:NSMakeRange(n, 1)];
NSLog(@"character #%d: %@", n, character);
You can also set character
as the string value of a control. It should display just fine.
The key take-away: byte[i]
is NOT necessarily the same thing as the *i*th character. Text is always encoded, and you must always be (painfully) aware of that.