Sometimes I copy one-line scripts into the terminal from PDF files. Since they are copied from PDFs, sometimes they contain “shady” characters, such as non-breaking space, which breaks the script. Is it possible to highlight such characters (e.g., any non-ASCII ones or at least the non-breaking space) in Terminal or iTerm2? Or, instead, to automatically replace them with something else (e.g., non-breaking space with regular space)?
Maybe paste them into a plaintext text editor first (one that displays text only and preserves no formatting)? I think the free version of BBEdit can automagically clean up those kinds of characters with its “Zap Gremlins” feature, but in any plaintext editor should be able to help you clear out the cruft.
This wouldn’t be convenient enough for me. Instead of using BBEdit, I might create a simple script, but I’m looking for a solution that won’t require any additional clicks or keypresses.
Sounds like something PopClip could do, but I looked at the very long list of actions. Closest is “Slugify” action, but not quite. Perhaps you could get the app and then lobby them to make this action. Probably useful to all users.
Good idea, thank you.
This may (or may not) work, but using ⌘⌥⇧V will paste just the plain text without any formatting.
Bane of my computing life.
I maintain a small database (in SQLite3 — well it is a standard compontent of macOS after all). It contains electoral roll information from the local council. Part way through this year’s election cycle without any warning or notification the council started using non-breaking space in postcodes and this broke many of the scripts for the database. Took me a while to find why the scripts failed when on screen spaces and non-breaking space look identical. Hate them!