Subject: Escape sequences treated as visible characters, long characters split

From: Fabian Röling <[email-masked]>
Date: Fri, 3 Dec 2021 00:53:40 +0100

"fold" includes the character '\e' and each of the following characters
that are used to format text as if they were all visible.
Example:
echo "a\e[3mb\e[0mc" | fold -w1
Result:
a

*b*

c
It still formats correctly, it just breaks too early.
Special characters can even be broken up.
Example:
echo "君の名は" | fold -w1
Result:
�
�
�
�
�
�
�
�
�
�
�
�
In case this appears invisible or otherwise different: It's 12 lines with
one "tofu"/U+FFFD/replacement character each.
I would maybe expect issues like this when the "-b" option is given, since
that counts bytes, but it happens even without it.

While trying to work around this, I noticed a similar issue with "wc":
echo -e "\e[3ma\e[0m" | wc -cm
     10      10
I have not investigated this further so far.