From 707fb36d61cacff160309fcebd8aded7e76d36d8 Mon Sep 17 00:00:00 2001 From: John Gardner Date: Wed, 22 Dec 2021 19:11:38 +1100 Subject: [PATCH] Explain how U+00A0 can be inserted into a program on macOS --- SC1018.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/SC1018.md b/SC1018.md index b908900..def7579 100644 --- a/SC1018.md +++ b/SC1018.md @@ -1,7 +1,13 @@ # This is a unicode non-breaking space. Delete it and retype as space. -You copy-pasted some code, probably from a blog or web site, which for formatting reasons contained unicode no-break spaces or unicode zero-width spaces instead of regular spaces or in words. +You copy-pasted some code, probably from a blog or web site, which for formatting reasons contained Unicode no-break spaces or Unicode zero-width spaces instead of regular spaces or in words. To humans, a zero-width space is invisible and a non-breaking space is indistinguishable from a regular space, but the shell does not agree. -If you have just a few, delete the indiciated space/word and retype it. If you have tons, do a search&replace in your editor (copy-paste an offending space into the search field, and type a regular space into the replace field), or use `sed -e $'s/\xC2\xA0/ /g' -e $'s/\xE2\x80\x8b//g' -i yourfile` to remove them. +If you have just a few, delete the indicated space/word and retype it. If you have tons, do a search-and-replace in your editor (copy-paste an offending space into the search field, and type a regular space into the replace field), or use the following command to remove them: + +```sh +sed -e $'s/\xC2\xA0/ /g' -e $'s/\xE2\x80\x8b//g' -i yourfile +``` + +On macOS, a non-breaking space can be inserted into most programs by holding ⌥ Option+Space.