Question

I have a php script that enters a url string into a mySQL database. The url is sendt by an iphone app written in objective-c. It works fine except when the url code contains a scandinavian letter like ø, æ, or å. Example:

NSString *myString =[NSString alloc]initWithFormat:@".../myphp.php?Name=Strøm];
NSURL *myUrl =[NSURL URLWithString:[myString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSLog (@"String: %@",mysTring);
NSLog (@"URL: %@",myUrl);
NSMutableURLRequest *req=[NSMutableURLRequest requestWithURL:myUrl];
NSURLConnection *connection=[[NSURLConnection alloc]initWithRequest:req delegate:self startImmediately:YES];

Output:

String .../myphp.php?Name=Strøm

URL: .../myphp.php?Name=Str%C3%B8m

Problem: When the URL is delivered by the app, "ø" is turnded into "ø" in the mySQL database. When the URL is entered into the url field of a browser, the "ø" is written correct.

Somehow, I think something is wrong with the urlrequest. Is there a way to fix this problem?

Was it helpful?

Solution

The solution is to encode symbols into special character set on the client side and decode them on the server side.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top