Weird issue when printing String with unicode character

If I go into the REPL in Swift 4.1.2 (swiftlang-902.0.54 clang-902.0.39.2) and type in the string "\u{8d}" the REPL will instead echo

$R9: String = "\u{c2}"

back to me.

This doesn't seem to be a problem in the actual representation of the string: When I inspect the individual characters, the correct value is stored. Also, calling print with it works "fine" (it's not really a printable character, but at least it doesn't print "Â", which is what "\u{c2}" would resolve to).

This doesn't just happen in the REPL but also when debugging etc.

Can anyone reproduce this? Is this a known bug, or what's going on?

print and debugPrint are behaving correctly. My guess is that the REPL is accidentally printing the first byte of the UTF-8 representation of U+008D (C2 8D), but it might be something else. Can you file a bug at https://bugs.swift.org?

for reference: [SR-8111] Weird issue when printing String with unicode character · Issue #4493 · apple/llvm-project · GitHub

1 Like