字符串 -> UTF8字符串:

let baiduStr = "https://www.baidu.com/s?wd=央视新闻"

let  baiduStr_utf8 = baiduStr.addingPercentEncoding(withAllowedCharacters: CharacterSet.urlQueryAllowed) ?? ""

// “https://www.baidu.com/s?wd=%E5%A4%AE%E8%A7%86%E6%96%B0%E9%97%BB"

UTF8字符串 -> 字符串:

let baiduStr_utf8 = "https://www.baidu.com/s?wd=%E5%A4%AE%E8%A7%86%E6%96%B0%E9%97%BB"

let baiduStr = baiduStr_utf8.removingPercentEncoding

//  "https://www.baidu.com/s?wd=央视新闻"