iOS编码解码(Object-c)

///编码

NSString *urlString = [NSString stringWithFormat:@"%@UserInfo.php",@"UserInfo.php"];
urlString = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];///iOS9.0以下
urlString = [urlString stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];///iOS9.0以上

///解码

_String = [_String stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];///iOS9.0以下
_String = [_String stringByRemovingPercentEncoding];///iOS9.0以上

你可能感兴趣的:(iOS编码解码(Object-c))