Using CKEditor, when a double space is added (whether by mistake or to intentionally force a layout) the result is a "& nbsp;" entity. When passed through HtmlToText(), this ends up as a literal "& #160" in the plain text rather than a " ".
Hey @Neil Munro
This is expected behavior. CKEditor converts double spaces into to preserve layout, and HtmlToText() correctly converts into a non-breaking space (Char(160)), not a normal space.
Workaround: Normalize the text after conversion:
Replace(HtmlToTextResult, Char(160), " ")This converts non-breaking spaces into regular spaces when layout preservation is not needed.
Hi, thanks for the quick reply. Personally I don't think this behaviour is very helpful - the function is called HtmlToText() - so why is it converting to an HTML entity? Within a plain text output, it should be converted to another space, which will retain the original format, for example when saving to a file.
Hey @Neil Munro I understand your concern, but HtmlToText() isn’t converting to an HTML entity—it’s converting into its Unicode text equivalent (U+00A0) to preserve semantic whitespace. That’s why you see it in plain text.
That said, for exports/files where this isn’t useful, the practical solution is to normalize it:
Replace(TextFromHtml, Char(160), " ")
This converts non-breaking spaces into regular spaces and gives the expected plain-text output.