iOS objective C NSData to NSString return nil <p><code>data</code> is downloaded from website, </p> <pre><code>NSString * html = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; </code></pre> <p><code>html</code> is <code>nil</code>, but </p> <pre><code>NSString * html = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding]; </code></pre> <p>will have the content. Since the website contains Chinese characters, if using Ascii, the Chinese cannot be displayed. I guess there are some invalid UTF-8 in the website, so that make the first code not working.</p> <p>Is there any methods can keep using UTF-8 but ignore some invalid error?</p>