Swift
let str : NSString = CFURLCreateStringByAddingPercentEscapes(nil, dic, "!*'();:@&=+$,/?%#[]" as CFString, nil, CFStringBuiltInEncodings.UTF8.rawValue) // let str : NSString = dic.addingPercentEncoding(withAllowedCharacters: NSCharacterSet.urlQueryAllowed)! as NSString // let str : NSString = dic.addingPercentEscapes(using: String.Encoding.utf8.rawValue)! // let str : NSString = dic.addingPercentEncoding(withAllowedCharacters: NSCharacterSet(charactersIn:"`#%^{}"[]|\<> ").inverted)!
OC //编码 - (NSString *)encode { CFStringRef strRef = CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)self, NULL, NULL, kCFStringEncodingUTF8); return (NSString *)CFBridgingRelease(strRef); }
经过上面的编码即可加载出图片