-
Notifications
You must be signed in to change notification settings - Fork 11
Description
Some providers require url encoding or decoding using non-utf8 charsets. This behavior has been deprecated by Apple for some years now.
tripkit/Sources/TripKit/Util/HttpClient.swift
Lines 179 to 189 in d9a95d5
| 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.