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

Unicode width not being accounted for #349

Open
nithinmuthukumar opened this issue Jun 28, 2023 · 8 comments
Open

Unicode width not being accounted for #349

nithinmuthukumar opened this issue Jun 28, 2023 · 8 comments
Labels
question Further information is requested

Comments

@nithinmuthukumar
Copy link
Contributor

Characters with variable width break the table borders.
Example:
Screen Shot 2023-06-28 at 12 18 23 PM

@nithinmuthukumar
Copy link
Contributor Author

I'm willing to help, if you could point me in the right direction

@zhiburt
Copy link
Owner

zhiburt commented Jun 28, 2023

Hi @nithinmuthukumar

Could you provide your example?

I just wonder if you used color feature? (it's often nessary in such context)

@zhiburt zhiburt added the question Further information is requested label Jun 28, 2023
@daywalker90
Copy link

I'm encountering the same problem. What does the color feature have to do with this? Is there something i can do, besides filtering unicode characters?

@daywalker90
Copy link

daywalker90 commented May 4, 2024

It's not all characters but these 2 i found causing issues: ☀️🏛️
EDIT: I can see that tabled only prints the left side of these characters

@zhiburt
Copy link
Owner

zhiburt commented May 5, 2024

Hi @daywalker90

Could you provide a code example?

What does the color feature have to do with this?

It was renamed to ansi in recent releases.
But it changes the calculations a little bit.
But to be honest in this specific case, it mustn't be different.

It's not all characters but these 2 i found causing issues: ☀️🏛️

Generally speaking it all depends on a terminal.
If you render the same table, which includes some obscure utf8, in different terminals it may (likely) be different.

@zhiburt
Copy link
Owner

zhiburt commented May 5, 2024

Generally speaking it all depends on a terminal.
If you render the same table, which includes some obscure utf8, in different terminals it may (likely) be different.

Now I am thinking maybe it's worth to add a configuration for it.
I mean we can't fetch information from a terminal,
But we could be given it.

Either a complete UTF-8 map or some specifics like this particular char will take not 1 but 3 terminal columns.
Yee It could could be usefullllllllllllllllllll rarely, but would slow down rendering a fair bit.
So maybe would need to be hidden by a feature.

Just thoughts here.

@daywalker90
Copy link

daywalker90 commented May 5, 2024

You are right, it's highly terminal related. With putty i have these 2 above misbehaving and with powershell it's a complete mess. (i know, windows... yikes)

pub async fn qwert(
    plugin: Plugin<()>,
    _args: serde_json::Value,
) -> Result<serde_json::Value, Error> {
    let row1 = TableTest {
        name: "test1".to_string(),
    };
    let row2 = TableTest {
        name: "test☀️".to_string(),
    };
    let mut rows = Vec::new();
    rows.push(row1);
    rows.push(row2);
    let table = Table::new(rows);
    Ok(json!({ "format-hint":"simple",
        "result": table.to_string() }))
}

image

@zhiburt
Copy link
Owner

zhiburt commented May 6, 2024

See xterm

image

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

No branches or pull requests

3 participants