How can I decode a string in swift? The string is now test%2Enl
, but the correct format is test.nl
.
I now have this:
let encodedData = encodedString.dataUsingEncoding(NSUTF16StringEncoding)!
let attributedOptions = [NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType]
let attributedString = NSAttributedString(data: encodedData, options: attributedOptions, documentAttributes: nil, error: nil)!
return attributedString.string
You can use stringByReplacingPercentEscapesUsingEncoding
var properString = s.stringByReplacingPercentEscapesUsingEncoding(NSUTF8StringEncoding)!
Update for swift 3:
Use removingPercentEncoding
instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With