It will be as invisible as the space you type in to replace it, but it works beautifully. NOTE: If you forget the U+00A0 code, you can Select and Copy one of the  ’s, then Paste it into the find area. As blindy helpfully noted, a find/replace is so much easier. Microsoft’s and others “tutorials” for this problem suggest similar ways of combining of the SUBSTITUTE, CHAR and TRIM functions to accomplish this.ĭon’t even try – it’s ludicrously cumbersome. Just ran into this problem today….Unbelievably, in another example of Microsoft’s sometimes incredible stupidity: The CLEAN text function in Excel will remove non-printable characters….EXCEPT for the non-breaking space /  .
So, the moral of the story: be very careful when copying from HTML pages and pasting them into Word. It was like a genetic defect, passed down hidden through generations until it finally manifested. So, this bad character had been passed through generations of systems from an HTML page to Word to our web application to our database to the generated report to excel. The non-breaking space had been copied into Word. I then turned on “Show all nonprinting characters”, and there was the squiggle. I then opened it in a web browser, copied the text, and pasted it into Word. As an experiment, I created a simple web page that had a single line of text with an “ ” at one spot instead of a space. Where had I seen non-breaking spaces before? They are very common in HTML. It doesn’t appear to have been Word making changes automatically like it does with quotation marks, since it is only at this particular place. It seems that somehow a non-breaking space was introduced into our document. For example, if you wanted to make sure that “New York” was treated as a single phrase and did not wrap text in the middle of it (with one line ending on “New” and the next one starting on “York”), you could put a non-breaking space in there to stop it. The idea of a non-breaking space is that it separates two words but does not allow the text layout engine to choose it as a place for a line break. Microsoft Word supports them, but for their original purpose – non-breaking spaces. You use a non-breaking space when you want several spaces to really be rendered. In HTML, all spaces are considering non-essential, so if you have five in a row, the browser will just render a single space.
Web developers are very familiar with it as the “ ” string, which is used to force the web browser to render a space. It turns out that is a non-breaking space. I then googled the “” and came across a Stack Overflow discussion amongst some engineers about what it was.
I checked a variety of lists of non-printable characters Word uses, but it never seemed to appear. But clearly Word understood it to be something different. Without the non-printing characters on the screen, it looked just like a space. The result becomes 13 rather than 10.A space is normally represented as just a dot, but this is something different The following example fails if followed by "bar". Strings.TrimFunc can not detect if the input chars are "Douglas\u200b" + "bar". I often use strings.TrimFunc, but I have found that strings.Map() detects invisible chars better than strings.TrimFunc.