Hacker News new | ask | show | jobs
by JoshTriplett 2202 days ago
This only works if you're not dealing with Unicode, where the number of bytes, the number of characters, and the width of those characters can all vary.
2 comments

You don’t need Unicode for that. It also requires you use a monospaced font.

I think the feature predates that and Unicode, though. But even then, it fails if you underline text the way it was done at the time, either by using backspace and underline characters or by using termcap (https://en.wikipedia.org/wiki/Termcap)

This makes me wonder if there's some sort of Unicode equivalent for this?
wcwidth()
Thanks, I wasn't aware of this. Here's a man page for anyone else that was interested: https://man7.org/linux/man-pages/man3/wcwidth.3.html