Skip to content

df: Is printing the raw string guarenteed to have the same cell width as using the lossy string? #11987

@ChrisDenton

Description

@ChrisDenton

See this code:

/// Create a cell from an `OsString`
fn from_os_string(os: &OsString) -> Self {
Self {
bytes: uucore::os_str_as_bytes(os).unwrap().to_vec(),
width: UnicodeWidthStr::width(os.to_string_lossy().as_ref()),
}
}

It gets the width of the lossy string but stores the raw bytes. I think this at least deserves a comment explaining this is intentional. Because it's not entirely clear to me if doing a lossy conversion may use more or less cells.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions