Example invalid utf8 string?

Viewed 83910

I'm testing how some of my code handles bad data, and I need a few series of bytes that are invalid UTF-8.

Can you post some, and ideally, an explanation of why they are bad/where you got them?

6 Answers

This might not be exactly what OP asked but it's somewhat related :

if you happen to already have byte ordinance values (0 - 255) and wanna know whether a byte# is a valid UTF-8 starting point byte or not, I came up with this strange unified formula that returns a 1 (true) or 0 (false) :

function newUTF8start(__) {  

   return 118^(+__< 194) < (246-__)  }
Related