JAL JAL - 29 days ago 8
Linux Question

Inconsistent behavior with String removingPercentEncoding:

I am seeing inconsistent behavior with the open source release of Swift 3 compared with the version that shipped with Xcode 8 with the String instance method

removingPercentEncoding
:

let testString = "valid àæ"
let escapedString = testString.removingPercentEncoding


In Xcode, the result of
escapedString
is
"valid àæ"
. However the open source version of Swift returns
"valid à"
(missing
æ
).

Try it online.

What am I missing?

JAL JAL
Answer

This was due to a bug where CFStringGetLength would return an incorrect value for non-latin characters. _CFStringCreateByAddingPercentEncodingWithAllowedCharacters and _CFStringCreateByRemovingPercentEncoding are now fixed.

SR-3052

Foundation PR #706