android - 需要字符串解码帮助

标签 android ios swift string

我从 API 中获取了这种类型的编码字符串作为响应。我不知道使用了什么编码以及如何解码它。需要跨ios和android对其进行编码。

  1.5%23%23cups%23%23BISQUICK*+mix%23%23%0A0.333%23%23cup%23%23hot+water%23%23%0A3%23%23pieces%23%23eggs%23%23%0A1%23%23cup%23%23sour+cream%23%23%0A1%23%23cup%23%23Cheddar+cheese%23%23shredded%0A0.5%23%23cup%23%23green+onions%23%23sliced+%28about+4%29%0A0.5%23%23tsp%23%23onion+salt%23%23%0A1%23%23cup%23%23cooked+ham%23%23finely+chopped"

最佳答案

这是一个经过百分比编码的 URL 字符串(并非所有字符都可以在 URL 中发送,因此需要进行编码)。

使用该方法进行解码:

if let decodedString = yourString.removingPercentEncoding {
    // Do something with decodedString here
}

This answer显示如何将此编码和解码作为扩展添加到 String 类型。

关于android - 需要字符串解码帮助,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50555820/

相关文章:

ios - 来自外部来源的 ImagePicker 而不是相册

ios - 如何在 Storyboard 中的选项卡栏上启动导航 Controller 的第三个 View Controller

ios - 使用 drawInRect 调整图像大小,同时保持像 Scale Aspect Fill 这样的纵横比?

ios - 如何在 viewDidAppear 之前知道 tableView.contentSize?

android - Android Facebook 登录中不调用回调函数

java - SQL从一个表中删除+一个可连接的表?

java - 制作app后如何使用proguard

iOS swift 解析推送通知,推送发送 0

swift - Swift 中的惰性属性初始化

java - onStart 先于 onCreate 完成的原因