Javascript string to bytes utf 8. It throws an error when malformed UTF-8 is detected