Prevent errors if the string to be escaped is not in UTF-8