Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Handle utf8 nicks with mk_wcwidth() #480
thank you very much for your continued effort on this, I'm looking forward to integrating this into irssi.
mhm, it looks like we don't need the characters count and probably never will. (my suggestion was in error) how would you like renaming string_chars_for_width and make it return the bytes instead?
I'm a bit ambivalent about the policy-autodetection with -1 (tending to dislike). anyone else got an opinion on that? @dequis ?
Actually, the function returns the amount of characters and optionally provides the number of bytes. It turns out that my former pull request needed characters whereas my new pull request needs bytes; therefore, it does not seem unlikely to me that the number of characters could be needed in the future (never say never...). Plus, "he who can do more can do less": it does not hurt to have extra features like this in that kind of toolbox (because this is what we are doing here: glib and libc functions are not sufficient for us, so we are building our own little toolbox on top of them); for instance: have you noticed that string_length() is absolutely unused as of now? :)
I implemented that approach because, when writing the code, it seemed obvious to me that, without this mechanism, we would just end up writing a lot of "foobar(str, string_policy(str))" everywhere in the code and possibly regret it at some point as it goes against one of the most fundamental principle of programming: DRY -- Don't Repeat Yourself. How come you disapprove of it?