The problem with getCharacters:range:is that it gives you UTF-16 ( unichars) characters , while you want ASCII.
*(ResType*)[aString UTF8String] UTF-8 ( ASCII, ASCII), ResType. , , .
- getBytes:maxLength:usedLength:encoding:options:range:remainingRange: , NSASCIIStringEncoding NSUTF8StringEncoding, ResType, - 4 ( sizeof (ResType)).
:
, . , , . :
int main() {
int code = 'RTF ';
printf("'%c%c%c%c' = %d\n", ((char*)&code)[0], ((char*)&code)[1],
((char*)&code)[2], ((char*)&code)[3],
code);
}
' FTR' = 1381254688. , NSString , :
- ( ),
0 3 1 2. - , " ", .
- ( )
characterAtIndex: . , characterAtIndex: UTF-16, ASCII, ASCII.