Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

stringByAddingPercentEscapesUsingEncoding not working with NSStrings with ' 0'

Tags:

iphone

nslog

I have been having some problem with the stringByAddingPercentEscapesUsingEncoding: method. Here's what happens:

When I try to use the method to convert the NSString:

"..City=Cl&PostalCode=Rh6 0Nt"

I get this this..

"City=Cl&PostalCode=Rh62t"

It should be:

"..City=Cl&PostalCode=Rh6%200Nt"

What can I do about this? Thanks in advance !!

like image 256
Susanth Avatar asked Nov 28 '22 08:11

Susanth


1 Answers

For me, this:

NSString *s=[@"..City=Cl&PostalCode=Rh6 0Nt" stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSLog(@"s=%@",s);

... outputs:

s=..City=Cl&PostalCode=Rh6%200Nt

You're most likely using the wrong encoding.

like image 137
TechZen Avatar answered Dec 24 '22 18:12

TechZen