-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Output table padding formatter goes wrong with UTF8 characters #251
Comments
Which version of Ruby is this with? |
MRI 1.9.3p0 |
So I'm not sure how one expects Multibyte characters that don't fit the width of an ASCII Character to line up. Also, I assume this is for the pretty formatter output? |
Yeah I'm of the mind that we shouldn't spend time trying to fix this. Anything we could do would be complicated. We'd have to some how compute the size of the character being displayed, not simply the amount of characters being displayed. @mattwynne, thoughts? |
I'm second to @dkowis let'd do not spend time on this. It looks like a nice exercise in UTF area but adds nothing to Cucumber. @mattwynne @tooky do you agree? |
Some multibyte characters have width != 1:
Knowing whether a character has double width or not requires separate code: http://stackoverflow.com/questions/3634627/how-to-know-the-preferred-display-width-in-columns-of-unicode-characters Bikeshedding springs to mind :-) |
So, I'm closing the ticket. |
A simple solution might be to offer a setting on the API that allows the user to specify double-width characters. That way if someone suffers from this, and they care enough about it, they can fix the problem by explicitly configuring Cucumber to display those characters as double-width. e.g. in Cucumber.configure do
config.determine_console_character_width do |character|
['日', '本', '語'].include?(character) ? 2 : 1
end
end If nobody has called this configuration block, we assume everything is a 1. It would be trivial to change Cucumber to use this lookup. That would also open up for someone to write a plugin that used one of the C libraries @aslakhellesoy referenced. If anyone wants to write a PR for this, that's what I'd recommend they do. |
I thought widths could be fractional, like 1.4. |
@aslakhellesoy ah, so that would make our implementation non-trivial. Is that what you're saying? |
Yes. See the SO I linked to |
Yeah, when I looked at it, it would end up being a fractional width, which is basically impossible to do on the console. The way I think, if you want to do mixed languages, you should probably output to something that deals with them better, rather than the console. The HTML formatter springs to mind. The pretty formatter is good enough in a pinch, but won't ever be perfect for stuff like this, IMHO. |
* Formatting and things * Added header from [#251](cucumber/common#251)
* Formatting and link fixing for [#1182](cucumber/common#1182) * Added header from [#251](cucumber/common#251)
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
The padding of the |'s goes wrong for the chinese input example.
The text was updated successfully, but these errors were encountered: