Skip to content
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

Add support for double-width characters #15

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ulidtko
Copy link

@ulidtko ulidtko commented Oct 23, 2015

Fix #14

@ulidtko
Copy link
Author

ulidtko commented Oct 23, 2015

I hope it's obvious from the code, but what I did is:

  • defined column_width function which takes into account wide characters;
  • cell_widths_for_row uses the above instead of plain len to properly calculate cell widths;
  • adjust_row for the most part works as before, except that difference is re-synchronized inside the loop by column widths instead of character offsets. Unfortunately, this'll work slightly slower than before — but I didn't encounter any noticeable slowdown on my 10kiB TSV file with 10 columns.

And no changes beyond that, pretty simple in fact.

@adzenith
Copy link
Member

Sorry for the huge delay! Looks great. I had a couple quick comments. Thanks for the PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants