Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo


#267 Badblocks status updates misses with multi-byte encoding

Göran Uddeborg

When running "badblocks -s" in the Swedish locale using UTF-8 character encoding, the message reporting status is moved one position to the left for each update. The last letter of the old message remans, so after a while I have a long string of "t":s filling my xterm. This does not happen int the English locale, nor does it happen in the Swedish locale if I use the single-byte encoding ISO-8859-1.

The Swedish translation of the message, "%6.2f%% done, %s elapsed", is "%6.2f %% klar, %s har gått". The third last letter is an a-ring, which takes two bytes to encode in UTF-8. Maybe a not too daring guess is that badblocks writes this message, then backspaces the number of BYTES in the message. But it actually needs to step the number of columns used by the string. (It could be different than the number of CHARACTERS, if there are 0 wide or 2 column wide characters in the string.)