ios - What is the difference between stringByAddingPercentEscapesUsingEncoding: and stringByReplacingPercentEscapesUsingEncoding: -


What impresses difference between the two methods stringByAddingPercentEscapesUsingEncoding: and stringByReplacingPercentEscapesUsingEncoding: ?

I have read many times and still have not found it.

In addition, is there a way to force those methods to "sign" the signals? ?

I have a base64 encoded (ie letters, numbers, plus slash) menu to urlencode and Using ended CFURLCreateStringByAddingPercentEscapes instead of the method of the above methods ...

  - (NSString *) urlencode: (NSString *) str {return (NSString *) CFBridgingRelease (CFURLCreateStringByAddingPercentEscapes (zero, (CFStringRef __bridge) str, zero, CFSTR ( "+ / "), KCFStringEncodingUTF8)); }    

Stringbraidlingprsapapsupingincoding Unicode * will change the character percent Escape format.

stringByReplacingPercentEscapesUsingEncoding will work in the opposite, save the percentage save in Unicode *.

* Actually there is no Unicode, but the encoding you have selected.

Example: NSString * rawText = @ "One Broadway, Cambridge, MA"; NSString * encodedtext = [raw text stringbearingadditionalprint espressoup encoding: NSUFF 8 string encoding]; NSLog (@ "encoded text:% @", encoded text); NSSTING * Decoded Text = [Encoded Text String ByerPlacing Pest Control Escoding Usage: NSTF 8 String Encoding]; NSLog (@ "original text:% @", decoded text);

Here is the output:

  encoded text: a 20% border, 20% of Cambridge,% 20MA text: Broadway, Cambridge, MA   

loss: stringByAddingPercentEscapesUsingEncoding not account ???? T encoded; ampersand safe characters (& amp) and the slash (/)

Workaround: Instead Foundation function CFURLCreateStringByAddingPercentEscapes uses.

Source:

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -