i want to download html code and save it to a html file.However, there are kinds of Encoding which are used into html files,such as NSUTF8StringEncoding,NSISOLatin1StringEncoding and so on. wethere it has a function that change the different files of encoding into the same,and when the webview load the html file,it looks like as normal.
Asked
Active
Viewed 108 times
0
-
Can you use [something like this](https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/occ/instm/NSString/dataUsingEncoding:)? – Jørgen R Jan 11 '13 at 07:25
-
follow is my code:-(void)saveHtml:(NSString*)_html encoding:(NSStringEncoding)_encoding { int contentLength = [_html lengthOfBytesUsingEncoding:_encoding]; NSData* data = [NSData dataWithBytes:[_html cStringUsingEncoding:_encoding] length:contentLength]; NSLog(@"data = %@",data); NSString* html = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; NSLog(@"****html = %@",html); } but the html is nothing – gohamgx Jan 11 '13 at 08:04