cocoa url编码与解码
编码:
stringByAddingPercentEscapesUsingEncoding:
Returns a representation of the receiver using a given encoding to determine the percent escapes necessary to convert the receiver into a legal URL string.
Parameters
- encoding
-
The encoding to use for the returned string.
Return Value
A representation of the receiver using encoding to determine the percent escapes necessary to convert the receiver into a legal URL string. Returns nil
if encoding cannot encode a particular character
解码:
stringByReplacingPercentEscapesUsingEncoding:
Returns a new string made by replacing in the receiver all percent escapes with the matching characters as determined by a given encoding.
Parameters
- encoding
-
The encoding to use for the returned string.
Return Value
A new string made by replacing in the receiver all percent escapes with the matching characters as determined by the given encoding encoding. Returns nil
if the transformation is not possible, for example, the percent escapes give a byte sequence not legal in encoding.