I cannot print color escape codes to the terminal

Akavall

When I run this script:

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

I expect to get

SO #in red letters

However, I get:

33[0;31mSO33[0m

When I ran similar script in Go or Python, I get the expected output. What is going on? What am I missing? How do fix this?

I am using:

$ rustc --version
rustc 1.3.0 (9a92aaf19 2015-09-15)
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.3 LTS
Release:    14.04
Codename:   trusty
ymonad

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")
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Animation inside terminal with escape codes

From Dev

How to not print escape sequence in terminal

From Dev

Terminal that supports all SGR ANSI escape codes

From Dev

Not able to print in color on terminal

From Java

Unable to Print ANSI Escape codes in Simply Scheme

From Dev

Issue with column command and color escape codes

From Dev

bash compgen result contains terminal color codes

From Dev

PhpStorm terminal window formatting/ ANSI color codes

From Dev

Terminal color codes not working in bash on my mac

From Dev

Where should I save color codes for the PS1 command line / terminal?

From Dev

Julia: print_with_color() in terminal

From Dev

Are the terminal color escape sequences defined anywhere for bash?

From Dev

Are the terminal color escape sequences defined anywhere for bash?

From Dev

How to save GNOME Terminal contents with ANSI escape codes?

From Dev

Can Terminal.app be made to respect ANSI escape codes?

From Dev

How to save GNOME Terminal contents with ANSI escape codes?

From Dev

Is there a list of ANSI color escape codes somewhere in the standard libraries?

From Dev

how to turn off ANSI escape color codes in rails 4 logs

From Dev

c++ ansi escape codes not displaying color to console

From Dev

Is it possible to use ANSI color escape codes in Bash here-documents?

From Dev

Print a 256-color test pattern in the terminal

From Dev

Print a 256-color test pattern in the terminal

From Dev

Using variables to store terminal color codes for PS1?

From Dev

I cannot print on Python

From Dev

How can I tell Vim to show ANSI escape codes properly?

From Dev

How can I get python ''.encode('unicode_escape') to return escape codes for ascii?

From Dev

bash and ansi escape codes

From Java

How can I parse Linux terminal colour codes?

From Dev

Can you use hex color values with vt100 escape codes c++

Related Related

  1. 1

    Animation inside terminal with escape codes

  2. 2

    How to not print escape sequence in terminal

  3. 3

    Terminal that supports all SGR ANSI escape codes

  4. 4

    Not able to print in color on terminal

  5. 5

    Unable to Print ANSI Escape codes in Simply Scheme

  6. 6

    Issue with column command and color escape codes

  7. 7

    bash compgen result contains terminal color codes

  8. 8

    PhpStorm terminal window formatting/ ANSI color codes

  9. 9

    Terminal color codes not working in bash on my mac

  10. 10

    Where should I save color codes for the PS1 command line / terminal?

  11. 11

    Julia: print_with_color() in terminal

  12. 12

    Are the terminal color escape sequences defined anywhere for bash?

  13. 13

    Are the terminal color escape sequences defined anywhere for bash?

  14. 14

    How to save GNOME Terminal contents with ANSI escape codes?

  15. 15

    Can Terminal.app be made to respect ANSI escape codes?

  16. 16

    How to save GNOME Terminal contents with ANSI escape codes?

  17. 17

    Is there a list of ANSI color escape codes somewhere in the standard libraries?

  18. 18

    how to turn off ANSI escape color codes in rails 4 logs

  19. 19

    c++ ansi escape codes not displaying color to console

  20. 20

    Is it possible to use ANSI color escape codes in Bash here-documents?

  21. 21

    Print a 256-color test pattern in the terminal

  22. 22

    Print a 256-color test pattern in the terminal

  23. 23

    Using variables to store terminal color codes for PS1?

  24. 24

    I cannot print on Python

  25. 25

    How can I tell Vim to show ANSI escape codes properly?

  26. 26

    How can I get python ''.encode('unicode_escape') to return escape codes for ascii?

  27. 27

    bash and ansi escape codes

  28. 28

    How can I parse Linux terminal colour codes?

  29. 29

    Can you use hex color values with vt100 escape codes c++

HotTag

Archive