Some byte sequences are apparently invalid in Unicode encodings, and I know that some languages (Python for one) throw an error when that happens.
My question is: what happens in Javascript when receiving such a sequence during an XMLHttpRequest or XDomainRequest? Does the resulting string:
- Get truncated when that happens?
- Skip the bad sequence and start at the next byte(s)?
- Continue decoding and only show the replacement � character when displayed?
If 3, then does the charCodeAt function return a valid character code?
Number 3 happens. It shows the � when displayed, and charCodeAt returns 0xFFFD, the � unicode character.