2022-10-17 url 中文转码

+ (NSString *)urlEncode:(NSString *)url {


    NSString *charactersToEscape =@"[]";

    NSCharacterSet *allowedCharacters = [[NSCharacterSet characterSetWithCharactersInString:charactersToEscape] invertedSet];

    NSString * urlStr = [url stringByAddingPercentEncodingWithAllowedCharacters:allowedCharacters];

    return urlStr;

}

+ (NSString *)urlDecode:(NSString *)url {


    NSString* decodedString = [url stringByRemovingPercentEncoding];

    return decodedString;

}

你可能感兴趣的:(2022-10-17 url 中文转码)