parses a given string, replacing foreign characters with their equivalent HTML code