Throw error if encoding character in utf8 fails