Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Url encoding/decoding deprecation warning for unsupported encoding #44

Open
alexander-albers opened this issue Oct 8, 2021 · 0 comments
Labels
wontfix This will not be worked on

Comments

@alexander-albers
Copy link
Owner

Some providers require url encoding or decoding using non-utf8 charsets. This behavior has been deprecated by Apple for some years now.

extension String {
public func decodeUrl(using encoding: String.Encoding) -> String? {
return (self as NSString).replacingPercentEscapes(using: encoding.rawValue)
}
public func encodeUrl(using encoding: String.Encoding) -> String? {
return (self as NSString).addingPercentEscapes(using: encoding.rawValue)
}
}

Those methods already have been removed from the Swift String class and are only available for NSString:
https://github.com/apple/swift-corelibs-foundation/blob/eec4b26deee34edb7664ddd9c1222492a399d122/Sources/Foundation/NSStringAPI.swift#L2165

Deprecation warning for NSString: Use -stringByRemovingPercentEncoding instead, which always uses the recommended UTF-8 encoding.

decodeUrl

  • used by Hafas Legacy with isoLatin1 encoding

encodeUrl

  • used by UrlBuilder
  • VBB, Linz and NVBW use isoLatin1 encoding

Currently, everything still works fine, but this url encoding/decoding may need to be reimplemented at some point in the future if Apple decides to completely remove the respective methods.

@alexander-albers alexander-albers added the enhancement New feature or request label Oct 8, 2021
@alexander-albers alexander-albers added the wontfix This will not be worked on label Nov 27, 2021
@alexander-albers alexander-albers removed the enhancement New feature or request label Feb 21, 2022
@alexander-albers alexander-albers pinned this issue Feb 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

1 participant