Fix for HTML strings containing non-ASCII characters

As proposed by evg1985