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

Reprint treat unicode emoji pairs a two characters rather than one #16

Open
quoimec opened this issue Jun 27, 2022 · 2 comments
Open

Reprint treat unicode emoji pairs a two characters rather than one #16

quoimec opened this issue Jun 27, 2022 · 2 comments

Comments

@quoimec
Copy link

quoimec commented Jun 27, 2022

Hello, I have encountered a strange problem with reprint. I use it to build a command line utility and needed to have functionality to select a region. I used emoji flags e.g: 🇫🇷 after the region name but this resulted in the formatting of the interface screwing up. What I think is going on is the unicode system for various emojis like flags or options is comprised of 2+ symbols. In the case above, the French flag is made by combining the symbol for F with the symbol for R. See the proposal document here: https://www.unicode.org/L2/L2009/09379-n3727-regionalindicators.pdf. Reprint views this as two separate characters though and prepares it self for a line of length x. When this is rendered out to a user however, the F+R characters are combined into a single character, so a line of length x - 1. This then screws up the following lines as the initial line length calculation is wrong. This problem is apparent across all the various combination emojis that cover cases like gender and race.

Happy to assist with fixing this issue, might need some direction on where I should be looking within the project.

@Yinzo
Copy link
Owner

Yinzo commented Jun 27, 2022

Thanks for your detailed description!
base on your description, the issue is cause by the wrong calculation of character width, which is located in here. It's now only using the single character to calculate its width, which ignore the situation that unicode may combine two character and display them as one.
I may try to figure out a new solution to calculate line width, to cover the unicode combination situation.

Also, any contribution is absolutely welcomed, and I will follow up this issue these days.

@Yinzo
Copy link
Owner

Yinzo commented Jun 27, 2022

I'm testing this issue on a Window 11 and Linux platform, seems the display width of emoji flag may diverse base on the support of display, width may be 1 or 2 columns.
the solution needs to cover these both situations.

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

No branches or pull requests

2 participants