-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
erroneous use of charwidth in rpad? #10825
Comments
I guess the issue here is whether |
@jiahao, what was the issue with width-2 characters in 4af443f? Conversely, what would you want to do with zero-width combining characters — should Or a third option: maybe |
I was using |
@jiahao, what does Sphinx consider to be a "character"? Any codepoint? Nonzero-width codepoints? Graphemes? |
I think Sphinx uses Python's definition of 1 char = 1 code point. >>> len("e\u0302") #Python 3.4.3
2
>>> len(u"e\u0302") #Python 2.7.6
2 |
In this case, you need a rewrite of rpad based on length(s) for your use-case. But I'm skeptical that this should be the default. |
Yes, unfortunately it looks like uses of |
(Not to mention the inconsistent handling of strings by displays. c.f. #3721) |
I really needs two Or a keyword parameter |
Padding based on columns feels like the most sensible behavior to me; the help text should be updated. I wonder if lpad and rpad should be refactored. They have duplicated code, and it would get worse if we added options. These operations could be written something like |
Deciding the real spaced needed for layouting (in console or something else, whatever) is extremely hard. for example, some CJK fonts may make |
The help text for this has already been updated to say that padding is based on columns. There are other kinds of padding you might want, but the column behavior is useful too. |
x-ref f65befe |
The text was updated successfully, but these errors were encountered: