You're right, but I think we can simplify it a bit though by not depending on the new String object:

```
    if(Encoding::precise_mbclen(ba->raw_bytes(), ba->raw_bytes() + n, enc->get_encoding()) != n) {
      invalid_codepoint_error(state, c);
    }

```