objective c - NSURLRequest with url containing special characters -
i'm having same problem as: nsurl special characters
but tried solution. can't nsurlrequest work åöä characters. if variable "string" contains åöä request return null. tried nsisolatin1stringencoding.
nsstring *encodedstring = [string stringbyaddingpercentescapesusingencoding:nsutf8stringencoding]; nsstring *urlstring = [nsstring stringwithformat: @"http://suggestqueries.google.com/complete/search?output=firefox&q=%@", encodedstring]; nsurl *url = [nsurl urlwithstring: urlstring]; nsurlrequest *request = [[nsurlrequest alloc] initwithurl:url];
this works: http://suggestqueries.google.com/complete/search?output=firefox&q=%c3%a5%c3%b6%c3%a4 (åöä)
any ideas?
edit: using debugger nsurl looks correct:
string __nscfstring * @"åäö" 0x0a77cd60 encodedstring __nscfstring * @"%c3%a5%c3%a4%c3%b6" 0x0a77fc40 url nsurl * @"http://suggestqueries.google.com/complete/search?output=firefox&q=%c3%a5%c3%a4%c3%b6" 0x0a79d1f0
solved: problem not nsurl how return nsdata interpreted.
Comments
Post a Comment