# D031 string_slice_not_char_boundary

URL: /docs/errors/D031
Markdown: /docs/errors/D031.md

> String.slice was given a byte offset that is not on a UTF-8 character boundary.

A runtime defect: the running program stops with it; no compile phase reports it, and `try` cannot catch it. `sakura explain D031` prints this explanation offline.

`String.slice` was given a byte offset that is not on a UTF-8 character boundary. Offsets are
bytes, not characters: derive them from the string itself rather than from a character count.

Runtime defects come from running programs, so `compiler/tests/ui` has no fixture for them; the explanation above names the repair.
