-
-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make runeWidth a public function #48
Comments
The implementation of a public return StringWidth(string(r)) That's because a single code point (rune) is not always a complete character. That's the whole basis of the The private My initial gut reaction was to say "no" because (1) such a method would not make sense and (2) you could always call But if it really helps users who want to switch over from |
Thanks for the clarification. I was actually mid reply when you posted your response and also realised many of the problems you just mentioned. I withdraw my request for this function to be made public (and will close this issue) as it makes no sense at all after your clear explanation. I'll direct my attention at looking how to get other packages to stop calculating rune width where they should instead be seeing the bigger picture of the string width. |
There are many modules using
uniseg
for theStringWidth
function but also could use aRuneWidth
function. Could this function be made accessible so there is no need for incorrect implementations to be used.Examples of another module providing both these functions.
RuneWidth
- https://github.com/mattn/go-runewidth/blob/master/runewidth.go#L307StringWidth
- https://github.com/mattn/go-runewidth/blob/master/runewidth.go#L322As you can see, the
StringWidth
function relies ofuniseg
. Any application usinggo-runewidth
forStringWidth
could swap directly over touniseg
for the same capability. Comparing the benchmarks of the functions shows nearly 2x faster performance foruniseg
.Unfortunately,
runeWidth
is not public so I am unable to compare the performance. I do not see any negatives with making this function public. Is this something you would consider changing?The text was updated successfully, but these errors were encountered: