zoukankan      html  css  js  c++  java
  • 将string转换成UTF8在进行请求

    在请求服务器时,如果参数中带有中文字符。就会报参数格式错误,需要将其转换成UTF8

    @interface NSString (NSURLUtilities)

     

    /* Adds all percent escapes necessary to convert the receiver into a legal URL string.  Uses the given encoding to determine the correct percent escapes (returning nil if the given encoding cannot encode a particular character).  See CFURLCreateStringByAddingPercentEscapes in CFURL.h for more complex transformations

     */

    - (NSString *)stringByAddingPercentEscapesUsingEncoding:(NSStringEncoding)enc;

     

    /* Replaces all percent escapes with the matching characters as determined by the given encoding.  Returns nil if the transformation is not possible (i.e. the percent escapes give a byte sequence not legal in the given encoding).  See CFURLCreateStringByReplacingPercentEscapes in CFURL.h for more complex transformations

     */

    - (NSString *)stringByReplacingPercentEscapesUsingEncoding:(NSStringEncoding)enc;

     

    @end

    代码如下:

                    @"keyword": [searchSoft.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],

  • 相关阅读:
    (九)排序——选择
    (八)排序——冒泡
    (七)排序算法
    (六)递归
    (五)栈
    (三)队列
    (二)稀疏数组
    Nessus号称是世界上最流行的漏洞扫描程序
    meterpreter ???
    IIS网站权限设置原则
  • 原文地址:https://www.cnblogs.com/superchao8/p/3326721.html
Copyright © 2011-2022 走看看