Reputation: 31
I have a problem using "stringWithContentsOfURL" to get source page of a web(chinese) Thinking using "NSUTF8StringEncoding" but didn't work(got null for result). My code looks like this
NSString *string = [NSString stringWithContentsOfURL:[NSURL URLWithString:@"http://www.morningstar.com.tw/download_pdf_2-1.aspx"] encoding:NSUTF8StringEncoding error:nil];
NSLog(@"html = %@",string);
replaced "NSUTF8StringEncoding" by "NSASCIIStringEncoding", did get a result but words are scrambled.
Thanks for the help!
Upvotes: 1
Views: 2310
Reputation: 55334
You need a different encoding:
NSStringEncoding encoding = CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingDOSChineseTrad);
You can also use kCFStringEncodingDOSChineseSimplif
for simplified chinese. Use encoding
in place of NSASCIIStringEncoding
or the other standard ones.
See the documentation for more encodings if these do not work properly.
Upvotes: 2