quentinmit/mosh — comment on commit 42da3c03a8d88e9f098695756186ec983e61c4cb
File:  line 0
By keithw:

Unfortunately it looks like the Mac isn't quite as Unicody as glibc, in that mbrtowc() on Mac will happily accept a UTF-8 sequence that specifies something that is not a Unicode scalar value (but is, instead, a code point in the range for UTF-16 surrogate pairs).

This is a problem because it means invalid UTF-8 input could percolate to invalid UTF-8 output from Mosh. (Since both glibc and Mac will happily let you _output_ a UTF-16 surrogate pair code point into an invalid UTF-8 sequence.)

I will write a change to Parser::UTF8Parser::input() that explicitly checks for these non-scalar-value wchar_t's so we can keep consistent and correct behavior of the terminal emulator on both platforms.