2

am working on some mobile apps that send requests from mobile to internet via Http Requests

the problem is that i send Arabic chars in this requests as parameters so i have to convert them from

UTF-8 to Percent Encoding

i have a java based solution here :

http://mrxprt.com/blog/?p=454

[at the bottom of post u will find English Details : ]

but my problem now with Objective-C , how can it be done ?!

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Yahia
  • 691
  • 1
  • 7
  • 24

1 Answers1

2

Try either

NSString *result =[sourceString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

or

NSString *result =(NSString *)CFURLCreateStringByAddingPercentEscapes(NULL,
                                                               (CFStringRef)sourceString,
                                                               NULL,
                                                               (CFStringRef)@"!*'\"();:@&=+$,/?%#[]% ",
                                                               CFStringConvertNSStringEncodingToEncoding(encoding));
RabinDev
  • 658
  • 3
  • 13