Home  >  Q&A  >  body text

objective-c - iOS url encode问题

有一个QueryString字符串,形如@"oauth_consumer_key=7w8q7wea43c0054d26958339d3413&oauth_nonce=9210314&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1315591869"
我想对它进行url转义,用了stringByAddingPercentEncodingWithAllowedCharacters方法,但是其中的"="和"&"并没有被转义。为什么?

[querySting stringByAddingPercentEncodingWithAllowedCharacters:
                   [NSCharacterSet URLQueryAllowedCharacterSet]];
黄舟黄舟2766 days ago450

reply all(2)I'll reply

  • 大家讲道理

    大家讲道理2017-04-17 17:55:26

    ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~:/?#[]@!$&'()*+,;=

    According to what is said here, the above are all legal, including = and &

    http://stackoverflow.com/a/1547940

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-17 17:55:26

    The symbols mentioned by the question do not require URLEncode

    reply
    0
  • Cancelreply