swift - 将字符串更改为有效的 url swift
问题描述
嗨,我想从源接收图像,但我意识到它有一些字符会在 swift Urlsession 上返回 nil 我想知道如何更改此 url
https://melovaz.net/wp-content/uploads/2019/12/¡Viva-Latino-2.jpg _
至
https://melovaz.net/wp-content/uploads/2019/12/%C2%A1Viva-Latino-2.jpg
使用swift所以我可以下载图片谢谢
解决方案
感谢这篇文章这篇文章
我应该使用
var urlString = originalString.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
推荐阅读
- jira - 仪表板中的 Jira Rich Filters 小部件:查询有长度限制
- r - 从字符串中提取时间戳并转换为 R POSIXct 对象
- python - 如何在 iOS Appium 上按“确定”弹出位置
- paypal - 邮递员的 PayPal 无效客户端错误 - 沙盒模式
- java - 错误 NDK Android Javac:错误:类名称,仅在显式请求注释处理时才被接受
- javascript - jQuery 通过其元素事件更新对象
- vba - 将 Newton Raphson 方法实现到 vba 时出错
- php - 在运行时安装调度程序
- ruby - 在多个跨度标签中抓取文本(Ruby 和 Nokogiri)
- r - 确定两个整数中数字前面的元素数:R