When pasted a single quote in WordPress, it shows ’
, which in source code it shows ’
and in iOS's UIWebView
, it shows â. (Similar for ‘
which shows â )
How to make iOS's UIWebView
showing correct punctuation ?
Here is the code block I use:
NSURL *bio_url = [NSURL URLWithString:@"XML_URL_HERE"];
NSURLRequest *request = [NSURLRequest requestWithURL:bio_url];
AFHTTPClient *client = [[AFHTTPClient alloc] init];
AFHTTPRequestOperation *operation = [client HTTPRequestOperationWithRequest:request
success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSError *error = nil;
GDataXMLDocument *doc = [[GDataXMLDocument alloc] initWithData:operation.responseData options:0 error:&error];
NSString *xpath = @"/response/content";
NSArray *nodes = [doc nodesForXPath:xpath error:&error];
NSString *content = [[nodes objectAtIndex:0] stringValue];
NSString *fullHTML = [NSString stringWithFormat:@"<!DOCTYPE html>\
<html>\
<head>\
<meta charset='utf-8'>\
<style type='text/css'>body { font-family: Arial; font-size: 9px; }</style>\
</head>\
<body>%@</body></html>", content];
[web_view loadHTMLString:fullHTML
baseURL:nil];
if (error) {
NSLog(@"Error creating XML: %@", error);
}
}
failure:^(AFHTTPRequestOperation* operation, NSError *error) {
}];
[operation start];
Note that I even construct a new HTML by myself in above code.
Here is the XML content :
<response>
<request>fetch_wp_page</request>
<content><![CDATA[<p>Content is not important. ‘ Right ’?</p>]]></content>
</response>