objective c - iphone: NSMutableURLRequest returns strange characters for MS Word style apostrophe -
we pulling content off our website using xml/nsmutableurlrequest , pulls through "curly" style apostrophe , quotes, ’ rather '. nsmutableurlrequest seems hate these , turns them strange \u00e2\u0080\u0099 string.
is there can prevent this? using method, should somehow telling use utf-8? or, missing something?
uiapplication* app = [uiapplication sharedapplication]; app.networkactivityindicatorvisible = yes; nsstring *urlstr = [nsstring stringwithformat:@"%@",url]; nsurl *serviceurl = [nsurl urlwithstring:urlstr]; nsmutableurlrequest *servicerequest = [nsmutableurlrequest requestwithurl:serviceurl]; [servicerequest sethttpmethod:@"get"]; nsurlresponse *serviceresponse; nserror *serviceerror; app.networkactivityindicatorvisible = no; return [nsurlconnection sendsynchronousrequest:servicerequest returningresponse:&serviceresponse error:&serviceerror];
nsurlconnection
returns nsdata
response. can take nsdata
response , turn string. take string, turn nsdata
object, utf-8 encoding along way, , feed nsxmlparser
.
example: (assuming response
nsdata
response request)
// long variable names descriptive purposes nsstring* xmldataasastring = [[[nsstring alloc] initwithdata:response] autorelease]; nsdata* tofeedtoxmlparser = [xmdataasastring datausingencoding:nsutf8stringencoding]; nsxmlparser* parser = [[[nsxmlparser alloc] initwithdata:tofeedtoxmlparser] autorelease]; // utilize parser...
Comments
Post a Comment