You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Why mosh forces NCURSES_NO_UTF8_ACS to be 1? #1127
Hi -- the reason is that Mosh follows Kuhn's "UTF-8 and Unicode FAQ for Unix/Linux" rules and ignores ISO 2022 stateful "locking shifts" to switch into the Alternate Character Set (ACS). Instead, the application just uses Unicode coded characters for the desired symbols directly, rather than "switching" to an alternate charset that the terminal can get stuck in if nothing switches back. We advertise this on the Mosh homepage ("Mosh will never get stuck in hieroglyphs when a nasty program writes to the terminal.")
Mosh is a newer, UTF-8-only, terminal so it has the luxury of only supporting the "new" behavior. The input to the Mosh terminal emulator state machine is always a UTF-8-encoded Unicode scalar value. But most terminal emulators originated in the "byte-by-byte" days, and so they support both "byte-by-byte" mode and "scalar-value-by-scalar-value" modes as input to the terminal state machine. Despite Kuhn's FAQ, most of them retained their legacy behavior, and continue to honor the ISO 2022 locking shifts, even in UTF-8 mode. (PuTTY is one exception that behaves more like Mosh.)
Meanwhile, applications (and libraries like ncurses) have no portable way to tell if the input to the terminal emulator's state machine is bytes or Unicode scalar values. (The TERM values weren't updated in this transition, and things like "xterm-utf8" only came much later.)
The NCURSES_NO_UTF8_ACS environment variable tells ncurses to use UTF-8 coded characters directly and not locking shifts to render the characters in the "alternate" charset.
Programs like screen, tmux, and luit can interpret the ISO 2022 locking shifts themselves and render them into ISO 10646 (Unicode) coded characters, so that's why these can show up okay in Mosh (and PuTTY) even if the application continues to use the ISO 2022 locking shifts! Of course then you can get stuck in hieroglyphs within the screen/tmux/luit session. Hope all this info is helpful!
Activity
keithw commentedon Jan 26, 2021
Hi -- the reason is that Mosh follows Kuhn's "UTF-8 and Unicode FAQ for Unix/Linux" rules and ignores ISO 2022 stateful "locking shifts" to switch into the Alternate Character Set (ACS). Instead, the application just uses Unicode coded characters for the desired symbols directly, rather than "switching" to an alternate charset that the terminal can get stuck in if nothing switches back. We advertise this on the Mosh homepage ("Mosh will never get stuck in hieroglyphs when a nasty program writes to the terminal.")
Mosh is a newer, UTF-8-only, terminal so it has the luxury of only supporting the "new" behavior. The input to the Mosh terminal emulator state machine is always a UTF-8-encoded Unicode scalar value. But most terminal emulators originated in the "byte-by-byte" days, and so they support both "byte-by-byte" mode and "scalar-value-by-scalar-value" modes as input to the terminal state machine. Despite Kuhn's FAQ, most of them retained their legacy behavior, and continue to honor the ISO 2022 locking shifts, even in UTF-8 mode. (PuTTY is one exception that behaves more like Mosh.)
Meanwhile, applications (and libraries like ncurses) have no portable way to tell if the input to the terminal emulator's state machine is bytes or Unicode scalar values. (The TERM values weren't updated in this transition, and things like "xterm-utf8" only came much later.)
The NCURSES_NO_UTF8_ACS environment variable tells ncurses to use UTF-8 coded characters directly and not locking shifts to render the characters in the "alternate" charset.
Some more info here: https://stackoverflow.com/questions/37845244/acs-characters-not-working-in-putty-even-with-export-ncurses-no-utf8-acs-1
keithw commentedon Jan 26, 2021
Programs like screen, tmux, and luit can interpret the ISO 2022 locking shifts themselves and render them into ISO 10646 (Unicode) coded characters, so that's why these can show up okay in Mosh (and PuTTY) even if the application continues to use the ISO 2022 locking shifts! Of course then you can get stuck in hieroglyphs within the screen/tmux/luit session. Hope all this info is helpful!
keithw commentedon Jan 26, 2021
And here is an original discussion thread from the very early days of Mosh: https://lists.gnu.org/archive/html/bug-ncurses/2011-02/msg00000.html
mrkn commentedon Jan 26, 2021
Thank you for explaining the reason in detail. It is very helpful for me.
trysten commentedon Aug 21, 2025
Finding this thread, years after struggling with the issue, i finally completely understand. Thank you.
For later visitors: if you are seeing issues when running commands with
sudo, it's because you need to preserve theNCURSES_NO_UTF8_ACSwithsudo -E