Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Ralle

macrumors newbie
Original poster
Jan 6, 2009
7
0
I live in Denmark and here we have 3 additional letters (æ,ø,å) and I am making GET requests for XML content but NSURL fails whenever I put in any of the characters. They have to be escaped somehow but I am not sure how. This is where I call NSURL:
NSURL *xmlURL = [NSURL URLWithString:URL];
 

Ralle

macrumors newbie
Original poster
Jan 6, 2009
7
0
It is taken from a UISearchBar.

NSString* search = [searchBox text];
NSString* purl = @"http://www.google.com/search?query=";
NSString* url = [purl stringByAppendingString:search ];
 

xsmasher

macrumors regular
Jul 18, 2008
140
0
Same way that you encode spaces and other special chars - stringByAddingPercentEscapesUsingEncoding

This code works for me:

Code:
	NSString *url = @"http://www.google.com/search?q=æøå";
	url = [url stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding ];
	xmlURL = [NSURL URLWithString:url];
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.