addingpercentencoding swift 5 code example
Example 1: urlencode string swift
let originalString = "test/test"
let escapedString = originalString.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed)
print(escapedString!)
Example 2: swift url encode string
var urlString = originalString.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)