Skip to content

tokio_console::config::ViewOptions::default() set "en_us.UTF8" to lang #393

@ymgyt

Description

@ymgyt

What crate(s) in this repo are involved in the problem?

tokio-console

What is the issue?

impl Default for ViewOptions {
    fn default() -> Self {
        Self {
            no_colors: false,
            lang: Some("en_us.UTF8".to_string()),  // 👈
            ascii_only: Some(false),
            truecolor: Some(true),
            palette: Some(Palette::All),
            toggles: ColorToggles {
                color_durations: Some(true),
                color_terminated: Some(true),
            },
        }
    }
}

lang: Some("en_us.UTF8".to_string()),

"en_us.UTF-8" is probably correct ? (with - between UTF and 8)

then

impl ViewOptions {
    pub fn is_utf8(&self) -> bool {
        if self.ascii_only.unwrap_or(false) {
            return false;
        }
        self.lang.as_deref().unwrap_or_default().ends_with("UTF-8") // 👈
    }
    //...
}

self.lang.as_deref().unwrap_or_default().ends_with("UTF-8")

in ViewOptions::is_utf8(), lang is assumed to be UTF-8

How can the bug be reproduced?

tokio-console gen-config > ./console.toml

bat console.toml | rg lang
lang = 'en_us.UTF8'

Logs, error output, etc

No response

Versions

tokio-console 0.1.7

Possible solution

set "en_us.UTF-8" to lang in Default::default in ViewOptions

Additional context

No response

Would you like to work on fixing this bug?

yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    S-bugSeverity: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions