Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Escaping special characters (ø, æ) for use inside a url

I try to display an image with a URL source in an iOS application, but it doesn't show up.

The url of the image is live example path.

When escaping this string using the following Objective-C code:

 NSString *url= [(NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)originalpath, NULL, CFSTR("øæ"), kCFStringEncodingUTF8) autorelease];

the result is (with encoding of øæ) : live xml path

All my files where the URLs are stored use text encoding (UTF-8).

How do I escape the URL in a right way, such that the image will be displayed?

like image 508
Najeebullah Shah Avatar asked Dec 13 '22 07:12

Najeebullah Shah


1 Answers

don't go for ascii encoding try it

NSString *URLString = [yourImagepath stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *url = [NSURL URLWithString:URLString];

I hope it will help you out.

like image 77
Zaksh Avatar answered Jan 29 '23 04:01

Zaksh