Skip to content

Commit

Permalink
fix(linux): Ignore case when detecting UTF-8 locales. (#1)
Browse files Browse the repository at this point in the history
The casing of locales is not consistent on Unix platforms. This change
transforms locale environment variable text to uppercase when searching
for "UTF8" and "UTF-8" in locale names.
  • Loading branch information
olson-sean-k committed Sep 27, 2021
1 parent 95ead82 commit 38082d2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ pub fn on(stream: Stream) -> bool {
let ctype = std::env::var("LC_ALL")
.or_else(|_| std::env::var("LC_CTYPE"))
.or_else(|_| std::env::var("LANG"))
.unwrap_or_else(|_| "".into());
.unwrap_or_else(|_| "".into())
.to_uppercase();
ctype.ends_with("UTF8") || ctype.ends_with("UTF-8")
}
}

0 comments on commit 38082d2

Please sign in to comment.