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.

- (NSString *)stringByAddingPercentEscapesUsingEncoding:(NSStringEncoding)encoding
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.

- (NSString *)stringByReplacingPercentEscapesUsingEncoding:(NSStringEncoding)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.

posted @ 2011-10-21 09:52  Piosa  阅读(429)  评论(0编辑  收藏  举报