In certain situations, however, TRIM() can’t do the job.

One space character commonly used in Web pages that TRIM() will not remove is thenon-breaking space.

Non-Breaking and Regular Spaces

Spaces are characters and each character is referenced by its ASCII code value.

Excel trim function

Ted French

The ASCII code for a non-breaking space is160.

The ASCII code for aregularspace is32.

The TRIM() function can only remove spaces that have an ASCII code of 32.

ASCII codeset table.

Wikimedia Commons

Different typestyles support different ranges of ASCII codes.

Then, the TRIM() function removes the standard spaces from the substituted string.

SUBSTITUTE() is useful for replacing anyASCII codewith any other.