How to fix unreadable ASCII characters in Swift

Issue #444

To avoid compiler error Unprintable ASCII character found in source file, from Swift 5, we can use isASCII.

Run this from the generator app that generates Swift code.

1
let normalized = weirdString.filter({ $0.isASCII })

For more check, see Character https://developer.apple.com/documentation/swift/character/3127011-isletter

Watch out for

  • Delete/House symbol ⌂ code 127 (0x7f)

The above does not seem to work, use find to find  character (copy Sublime Text to see 0x7f character)

1
find ./ -type f -exec sed -i '' -e 's///' {} \;

Comments