title: What does the index of an UTF-8 encoding error indicate?
body: <pre><code>fn main() {
      let ud7ff = String::from_utf8(vec![0xed, 0x9f, 0xbf]);
      if ud7ff.is_ok() {
          println!("U+D7FF OK! Get {}", ud7ff.unwrap());
      } else {
          println!("U+D7FF Fail!");
      }
  
      let ud800 = String::from_utf8(vec![0xed, 0xa0, 0x80]);
      if ud800.is_ok() {
          println!("U+D800 OK! Get {}", ud800.unwrap());
      } else {
          println!("{}", ud800.unwrap_err());
      }
  }
  </code></pre>
  
  <p>Running this code prints <code>invalid utf-8 sequence of 1 bytes from index 0</code>. I understand it's an encoding error, but why does the error say index 0? Shouldn't it be index 1 because index 0 is the same in both cases?</p>