0

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?

Pawan Rai
  • 3,434
  • 4
  • 32
  • 42
Tom Tallak Solbu
  • 559
  • 6
  • 20

1 Answers1

0

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

Igor Matyushkin
  • 778
  • 4
  • 4
  • Ok, but how to do that? The symbols are already utf-8 encoded as you see in line 2. The server side also decodes utf-8. The app encoded url works fine when the url is entered directly into a browser. It does not work when the app is delivering the url. – Tom Tallak Solbu Mar 16 '14 at 13:38