[스위프트3] URLEncoding/Decoding
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
/// 이스케이프 url
///
/// - Parameter string: 이스케이프할 URL문자열
/// - Returns:
static func urlEncodingForString(string:String) -> String{
return string.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed)!
}
/// 이스케이프 %
///
/// - Parameter string: 이스케이프할 URL문자열
/// - Returns:
static func urlDecodingForString(string:String) -> String{
let returnString = string.replacingPercentEscapes(using: String.Encoding.utf8)!
return returnString.replacingOccurrences(of: "+", with: " ")
}
| cs |
댓글
댓글 쓰기