iPhone: What are the different kinds of encodings that dataUsingEncoding supports?
Can anyone point me to any article or document that lists a开发者_如何学运维ll the encoding types that "dataUsingEncoding" in iPhone supports?
//This can print all of encoding that iPhone supports
NSMutableArray *arrayOfEncodings = [[NSMutableArray alloc] init];
const NSStringEncoding *encodings = [NSString availableStringEncodings];
while (*encodings != 0){
[arrayOfEncodings addObject:[NSNumber numberWithUnsignedLong:*encodings]];
encodings++;
}
for (int i=0; i<arrayOfEncodings.count; i++) {
NSStringEncoding aNSStringEncoding = [[arrayOfEncodings objectAtIndex:i] unsignedLongValue];
CFStringEncoding aCFStringEncoding = CFStringConvertNSStringEncodingToEncoding(aNSStringEncoding);
CFStringRef encodingNameInCFString = CFStringGetNameOfEncoding(aCFStringEncoding);
NSString * encodingName = (NSString*)encodingNameInCFString;
NSLog(@"%@", encodingName);
}
The NSString availableStringEncodings method will return a list of available encodings - the current (as of iOS 4.2) options being:
- NSASCIIStringEncoding
- NSUnicodeStringEncoding
- NSISOLatin1StringEncoding
- NSISOLatin2StringEncoding
- NSSymbolStringEncoding
[NSString availableStringEncodings]
精彩评论