The fold command doesn't support the UTF-8 encoding. I have the file, which contains: cat test.rst 123456789 123456789 123456789 ľščťžýáíé ľščťžýáíé ľščťžýáíé 123456789 123456789 123456789 123456789 ľščťžýáíé ľščťžýáíé ľščťžýáíé ľščťžýáíé And applying fold to set the the row length to 30 chars with this result: fold -w 30 test.rst 123456789 123456789 123456789 ľščťžýáíé ľščťž �áíé ľščťžýáíé 123456789 123456789 123456789 123456789 ľščťžýáíé ľščťž �áíé ľščťžýáíé ľ �čťžýáíé You can see, the some UTF-8 chars are broken (breaking UTF-8 2B chars). When applying the space braking: fold -sw 30 test.rst 123456789 123456789 123456789 ľščťžýáíé ľščťžýáíé ľščťžýáíé 123456789 123456789 123456789 123456789 ľščťžýáíé ľščťžýáíé ľščťžýáíé ľščťžýáíé The chars are not breaked, but the file is not wrapped for 30 chars. I expect, that the file will be wrapped as this: 123456789 123456789 123456789 ľščťžýáíé ľščťžýáíé ľščťžýáíé 123456789 123456789 123456789 123456789 ľščťžýáíé ľščťžýáíé ľščťžýáíé ľščťžýáíé regards Debian Release: jessie/sid 500 testing security.debian.org 500 testing ftp.cz.debian.org 500 stable deb.opera.com 200 testing www.deb-multimedia.org I set the important severity, because nowaday Debian's default is UTF-8 in terminal. regards
For what it’s worth, ‘fold’ from Busybox handles UTF-8 correctly: +$ busybox fold -w 10 << EOF +> 1234567890123456789012 +> Мы не рабы, рабы немы. +> EOF 1234567890 1234567890 12 Мы не рабы , рабы нем ы. +$ busybox fold -w 10 -s << EOF +> Мы не рабы, рабы немы. +> EOF Мы не рабы, рабы немы. (While in Coreutils the bug is still present.)
In fact, that seems to be a duplicate of Debian bug #139861 [1] dated 25 March 2002 (wow!). [1]: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=139861
forcemerge 139861 721324 thanks Dmitry Alexandrov wrote: You are right and I am merging the tickets. What I wrote there in https://bugs.debian.org/139861#91 still applies. The best course of action would be to get this resolved upstream with the functionally properly integrated. Until then this remains a known deficiency. Unfortunately actually getting code fixed isn't as easy as submitting a bug report and then magically a fix appears. For some simple things this may be easy. For very complex things like full UTF-8 support this is NOT EASY. Complex things like UTF-8 support will take MANY HOURS of EFFORT and REVIEW. If you think it is easy that is great because maybe you have the programming skills to get the job done. If anyone actually wants to get this working they should work within the upstream project to get the code written, to get the code reviewed, to get the code tested, and then finally get the code released. Bob