

it’s incorrect bc it destroys multibyte characters
It doesn’t. As the poster two levels up said, all bytes that don’t represent an ASCII character have the high bit set, even the follow-up bytes in multibyte sequences. So the condition b >= 32
will match and preserve them.
deleted by creator