text-input: correctly handle utf-8 sequences when backspacing