unicoqude/
lib.rs

1// unicoqude - easy-to check is your terminal
2// emulator has unicode support
3//
4// MIT License
5//
6// Copyright (c) 2021 Ferhat Geçdoğan All Rights Reserved.
7// Distributed under the terms of the MIT License.
8//
9//
10
11pub mod unicoqude {
12    pub fn check() -> bool {
13        #[cfg(target_os = "windows")]
14        return true;
15
16        #[cfg(target_family = "unix")]
17        match std::env::var("TERM").unwrap().as_str() {
18            "xterm-256color" | "alacritty" => return true,
19            _ => {}
20        }
21
22        false
23    }
24}
25
26#[cfg(test)]
27mod tests {
28    #[test]
29    fn ok() {
30        print!("{} ", "Your terminal emulator has");
31
32        match crate::unicoqude::check() {
33            true => {
34                print!("{} ", "support");
35            },
36            false => {
37                print!("{} ", "not support");
38            }
39        }
40
41        println!("{}", "unicode");
42    }
43}