0

I get a link from server to image has already been Encoding so it comes with %20 But sometimes I get a code include Hebrew characters, so I need to do Encoding agian , With the above code:

But after my Encoding i get in response that % 20 change to % 2520

static CFStringRef charsToEscape = CFSTR("&="); + (NSString *)escapeStringByAddingPercentEscapes: (NSString*) string { return [(NSString *)CFURLCreateStringByAddingPercentEscapes(NULL, (CFStringRef)string, NULL, charsToEscape, CFStringConvertNSStringEncodingToEncoding(NSUTF8StringEncoding)) autorelease]; } 

i tried to add % to charsToEscape like this:

static CFStringRef charsToEscape = CFSTR("&=%");

but it did not help.

thanks

2 Answers 2

2
NSString *urlString = @"----YOUR URL HERE----"; [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSURL *url = [NSURL URLWithString:urlString]; 
Sign up to request clarification or add additional context in comments.

Comments

1

Your idea is good if I did not get the Hebrew characters in the link.

But I found the solution , I just sent the % in the parameter legalURLCharactersToBeEscaped

now i use in the function like this:

static CFStringRef charsToEscape = CFSTR("&="); static CFStringRef charsUnchanged = CFSTR("%"); + (NSString *)escapeStringByAddingPercentEscapes: (NSString*) string { return [(NSString *)CFURLCreateStringByAddingPercentEscapes(NULL, (CFStringRef)string, charsUnchanged, charsToEscape, CFStringConvertNSStringEncodingToEncoding(NSUTF8StringEncoding)) autorelease]; } 

thanks

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.