zoukankan      html  css  js  c++  java
  • [iOS]URL编码和解码

    1. 首先来看下什么样的是URL编码(字符串中带有%22 类似这样的)

    NSString *str = @"http://m.tuniu.com/api/home/data/index/c/%7B%22v%22%3A%227.1.0%22%2C%22ct%22%3A20%2C%22dt%22%3A1%2C%22p%22%3A11210%2C%22cc%22%3A2500%7D/d/%7B%22clientModel%22%3A%22HONOR+H30-L01%22%2C%22width%22%3A720%7D"

    把URL解码

    // 解码

      NSString *str2 = [str stringByRemovingPercentEncoding];  (iOS9.0(包括9.0)以上使用)

      NSString *str2 = [str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];  (iOS9.0以下使用)

    把URL编码

    // 编码

      NSString *str3 = [str2 stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSetURLQueryAllowedCharacterSet]]; (iOS9.0(包括9.0)以上使用)

      NSString *str3 = [str2 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];  (iOS9.0以下使用)

  • 相关阅读:
    POI中文API文档
    接口
    JDK中的URLConnection参数详解
    RPC远程过程调用概念及实现
    tkinter 打包成exe可执行文件
    PHP 的命令行模式
    php CLI SAPI 内置Web Server
    ppython的移位操作
    HAProxy基础
    HAProxy用法详解
  • 原文地址:https://www.cnblogs.com/wangqi1221/p/5240237.html
Copyright © 2011-2022 走看看