On Sun, Jan 08, 2006 at 05:56:20AM +0000, Bart Schaefer wrote: > I prefer the \M- form because it gives you some clue what you should do > to generate the equivalent value from the keyboard. Fair enough -- let's just leave it alone, then. As for my patch in the grandparent email, I noticed some problems with it: the manpage for mbrtowc() says that the state of the mbstate_t object is undefined after the function returns -1, so the code should reset it to a known state. When the function returns -2, it means the code scanned to the end of the string without finding the end of a wide character, so perhaps we should treat all the remaining characters as invalid? I'm not certain that's the correct thing to do, so I'll leave the code handling -2 the same way as -1 for now. Finally, I wasn't setting the right visible width for the \M-... string (I had mistakenly hardwired it to "1"). While twiddling these things I noticed a couple other things that I think could be improved: 1. It looks to me like the code in wcs_nicechar() that calls wcswidth(&c, 1) could really just call wcwidth(c), right? If not, what am I missing? 2. The code in mb_niceformat() calls strlen() on the "fmt" string returned by wcs_nicechar(), but it seems to me that it could just use the width that wcs_nicechar() returned, right? Attached is an updated version of my patch that fixes the aforementioned bugs and implements the 2 improvements. ..wayne..