Patrick Steinhardt <ps@xxxxxx> writes: > Also, do you know why we didn't use `utf8_strwidth()` right from the > start? It would have saved the writer some time to just use > `utf8_strwidth()` instead of writing a whole paragraph explaining that > we should do it eventually. Makes me wonder whether there is anything > else going on here. I suspect that it is because it is not just that single strlen() call. The code assumed that byte count and display width were interchangeable, and use of strlen() there was merely an example. Starting there, the value returned by strlen() is treated as if it were interchangeable with a display width, and then later used to count how many bytes to trim from either end of the string so that the trimmed string would eventually fit a given display width, which means that the code to compute how much to trim (which is not that strlen() the patch in question is touching) would have to compute the reverse, i.e. "if we need to recover N display columns, how many bytes do we need to trim from that string?"