Decoding Percent-Encoded String in Swift 4.2?

797 views Asked by At

I'm trying to decode a percent-encoded string but can't figure out how to. For example:

let str = "Hello%20World"

// I want to decode 'str' to 'Hello World'

Does anyone know the best way to do this in Swift 4.2? Thank you.

1

There are 1 answers

0
matt On BEST ANSWER

To remove percent encoding, I would call the removingPercentEncoding method.

https://developer.apple.com/documentation/foundation/nsstring/1409569-removingpercentencoding