I cannot print color escape codes to the terminal

后端 未结 1 600
醉梦人生
醉梦人生 2021-01-18 10:33

When I run this script:

fn main() {
    // \\033[0;31m <- Red
    // \\033[0m <- No Color
    println!(\"\\033[0;31mSO\\033[0m\")
}

I

相关标签:
1条回答
  • 2021-01-18 11:27

    Rust 1.3.0 does not seem to support octal escape strings such as \033. Instead, you can use hexadecimal escape strings like \x1b.

    fn main(){
      println!("\x1b[0;31mSO\x1b[0m")
    }
    
    0 讨论(0)
提交回复
热议问题