简体   繁体   中英

How can i pass special character(like #,@,%,$) in NSRequestURL with GET method JSON Objective C

How can I pass NSRequestURL like http://ww.a.com/Account/CheckValidUser?username=abc&password=abc123# through JSON with HTTP GET Method to server?. Passpword contain # chracter. How i can send this with NSUrlRequest in objective c.

try this:

NSString *myRequestString = @"http://ww.a.com/Account/CheckValidUser?username=abc&password=abc123#"
NSString *requestStr = [myRequestString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

Encode your string with NSUTF8StringEncoding

You can consult this link which clearly provides what types of html special character codes are present : -

HTML special characters code List

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM