Fix crash when typing in multibyte characters