I have an NSString which contains data encoded with NSUTF8Encoding. I want to convert that string 开发者_Python百科into NSASCIIEncoding. Please tell me anyway to convert it in a proper manner. I am able to convert reverse (NSASCIIEncoding to NSUTF8Encoding).
Please provide any sample code.
Thanks in advance
I have an NSString which contains data encoded with NSUTF8Encoding.
Really? Because an Because you cannot be sure how an NSString
always treats its contents as UTF-16 internally.NSString
stores its data internally. Conceptually, NSString
works with UTF-16.
I want to convert that string into NSASCIIStringEncoding.
if ([myString canBeConvertedToEncoding:NSASCIIStringEncoding]) {
const char *asciiString = [myString cStringUsingEncoding:NSASCIIStringEncoding];
}
精彩评论