Yes, I know what you mean. The board strips spaces too.
As you can see, the only way to retrieve the correct number of spaces, is by using the internal identifier $chan(#channel).topic, because $3- of the raw event has already stripped the spaces.
You can also use that identifier in the on topic event, that occurs when someone changes the topic.