Check if NSData contains ASCII or UTF8 Encoding
I am retrieving HTML, containing UTF8 or ASCII encoded text. For most common use it is ASCII decoding that works to display the text right: NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSASCIIStringEncoding]; Now I have another HTML page with UTF8 encoding, so I have to use: NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]; What kind of encoding I retrieve is random when loading websites. My question is, is there a way to check the NSData for what kind of decoding is the right to use? So I know which