fix utf8 string handling

substr_replace() is not multibyte safe. Having utf8 encoded characters in the markup, breaks the html output.