Skip to content

fix: enable IUTF8 input flag by default on darwin pseudo-terminals - #218

Open
AdamMagued wants to merge 1 commit into
creack:masterfrom
AdamMagued:fix-darwin-iutf8-multibyte
Open

AdamMagued wants to merge 1 commit into
creack:masterfrom
AdamMagued:fix-darwin-iutf8-multibyte

Conversation

@AdamMagued

Copy link
Copy Markdown

Set the IUTF8 flag in termios c_iflag on Darwin pseudo-terminals during open.

On macOS, the kernel terminal driver defaults newly allocated pseudo-terminals to canonical mode without the IUTF8 flag enabled. When multibyte UTF-8 characters (such as CJK characters) are typed and subsequently erased with the Delete key (0x7f) or backspace, the terminal driver deletes only the final byte instead of the complete multibyte character, leaving corrupt byte sequences in canonical line buffers.

Enabling IUTF8 by default on the slave tty allows the terminal driver line discipline to correctly recognize multibyte UTF-8 character boundaries during line editing.

Fixes #138

Set the IUTF8 flag in termios iflag on darwin when opening a pseudo-terminal.
Without IUTF8, the Darwin terminal driver line discipline deletes single bytes
instead of whole UTF-8 characters when backspace/delete (0x7f) is sent, resulting
in mangled multibyte characters in canonical mode.

Fixes creack#138
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multibyte characters mangled on macOS

1 participant