gpt4 book ai didi

ios - 如何在 Swift 中从包含土耳其字符 (çıüöğ) 的字符串创建 URL

转载 作者:行者123 更新时间:2023-11-29 05:46:26 24 4
gpt4 key购买 nike

我正在为我的客户 WordPress 网站创建一个应用程序。当他上传 Assets 时,他有时会使用土耳其字符;例如:

https://example.com/wp-content/uploads/2019/05/Samsun-Büyük-güne-hazır.jpg

URL.init(string:) 不会将此视为有效的 URL。

那么我该如何处理这种情况呢?

谢谢。

最佳答案

let string = "https://example.com/wp-content/uploads/2019/05/Samsun-Büyük-güne-hazır.jpg".addingPercentEncoding(withAllowedCharacters: .urlFragmentAllowed)
let url = URL(string: string!)

关于ios - 如何在 Swift 中从包含土耳其字符 (çıüöğ) 的字符串创建 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56113491/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com