HomeFreeBSD

tty: fix improper backspace behaviour for UTF8 characters when in canonical mode

Description

tty: fix improper backspace behaviour for UTF8 characters when in canonical mode

This patch adds additional logic in ttydisc_rubchar() to properly handle
backspace behaviour for UTF-8 characters.

Currently, typing in a backspace after a UTF8 character will delete only
one byte from the byte sequence, leaving garbled output in the tty's
output queue. With this change all of the character's bytes are deleted.
This change is only active when the IUTF8 flag is set (see
19054eb6053189144aa962b2ecc1bf5087758a3e "(s)tty: add support for IUTF8
input flag")

The code uses the teken_wcwidth() function to properly handle character
column widths for different code points, and adds the
teken_utf8_bytes_to_codepoint() function that converts a UTF-8 byte
sequence to a codepoint, as specified in RFC3629.

Reported by: christos
Reviewed by: christos, imp
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D42067

(cherry picked from commit 9e589b0938579f3f4d89fa5c051f845bf754184d)
Approved by: re (gjb)

Details

Provenance
bnovkovAuthored on Oct 7 2023, 6:00 PM
christosCommitted on Oct 22 2023, 11:56 AM
Reviewer
christos
Differential Revision
D42067: tty: fix improper backspace behaviour for UTF8 characters when in canonical mode
Parents
rGad8c7f909e33: (s)tty: add support for IUTF8 input flag
Branches
Unknown
Tags
Unknown