`String.addingPercentEncoding(withAllowedCharacters: CharacterSet)` produces incorrect output when the string contains certain Unicode characters. It does not seem to matter which CharacterSet is used.
This issue occurs on Ubuntu 16.04, but does NOT occur on macOS.
Tested on Swift 3.0.1 Release and swift-DEVELOPMENT-SNAPSHOT-2016-11-12-a-ubuntu16.04.
Steps to reproduce:
let str = "CaféRio" // Accented "e"
let escaped = str.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed)!
Expected output: Caf%C3%A9Rio
Actual output: Caf%C3%A9Ri
Notice that the actual Unicode character is escaped correctly, but the resulting string is missing a character at the end. For each "é" inside the string, another trailing character goes missing.