I dont know how or where to add the correct encoding code to this iPhone code...
Posted
by BC
on Stack Overflow
See other posts from Stack Overflow
or by BC
Published on 2010-03-28T03:29:36Z
Indexed on
2010/03/28
3:33 UTC
Read the original article
Hit count: 271
Ok, I understand that using strings that have special characters is an encoding issue. However I am not sure how to adjust my code to allow these characters. Below is the code that works great for text that contains no special characters, but can you show me how and where to change the code to allow for the special characters to be used. Right now those characters crash the app.
enter code here
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if (buttonIndex == 1) {
//iTunes Audio Search
NSString *stringURL = [NSString stringWithFormat:@"http://phobos.apple.com/WebObjects/MZSearch.woa/wa/search?WOURLEncoding=ISO8859_1&lang=1&output=lm&term=\"%@\"",currentSong.title];
stringURL = [stringURL stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];
}
}
And this:
-(IBAction)launchLyricsSearch:(id)sender{
WebViewController * webView = [[WebViewController alloc] initWithNibName:@"WebViewController" bundle:[NSBundle mainBundle]];
webView.webURL = [NSString stringWithFormat:@"http://www.google.com/m/search?hl=es&q=\"%@\"+letras",currentSong.title];
webView.webTitle = @"Letras";
[self.navigationController pushViewController:webView animated:YES];
}
Please show me how and where to do this for these two bits of code.
© Stack Overflow or respective owner