Java print unicode
PrintWriter printWriter = new PrintWriter(System.out,true);
char s = '\u0905';
printWriter.println("Unicode = " + s);
Box Drawing PDF File
Terminal Color and Escape Code Sequence
Set Foreground Color | \x1b[38;5; {color code}m \x1b[0m |
Set Background Color | \x1b[48;5; {color code}m \x1b[0m |
Use 256 Colors in terminal
Set foreground color: \x1b[38;5; {color code}m \x1b[0m
Set background color: \x1b[48;5; {color code}m \x1b[0m
| | |
| | |-> reset color
| |-> RGB color (0-255)
|
|-> 38 => foreground
+-> 48 => background
24 bit RGB (Truecolor)
{r} {g} {b}
8bits 8bits 8bits = 24bits
32 bit RGBA
{r} {g} {b} {a}
8bits 8bits 8bits 8bits
2^10 = 1024
2^5 = 32 x 32 = 940 + 64 = 1024
2^24 = (2^10)^2 * 2^2 = 1024 x 1024 = 1M*2^2 = 4M
Set foreground color: \x1b[38;5; {r};{g};{b}m \x1b[0m
Set background color: \x1b[48;5; {r};{g};{b}m \x1b[0m
| | |
| | |-> reset color
| +-> RGB color (0-255)
|
+-> 38 => foreground
+-> 48 => background
Print console color string in Terminal
+ -> Use color_console find out the decimal code for different color
↓
printf '\x1b[38;5;200mHello\x1b[0m' # Hello (in Pink FG)
↑ ↑ ↑
| | +-> Pink, decimal
| +->
|
+-> Set foreground
printf '\x1b[48;5;200mHello\x1b[0m' # Hello (in Pink BG)
↑
|
+ -> Set background
printf "\033[31;1;4mHello\033[0m"
↑ ↑ ↑
| | + → 4 → Underline
| |
| + → 1 → Bold
|
+ → 31 → Red
echo -e "\033[5;1;31mHello World\033[0m"
↑ ↑ ↑
| | +- → 31 → Red
| + → 1 → Bold
|
+ → 5 → Blinking
"\033[X;Y;ZmHello World\033[0m"
↑ ↑ ↑
X Y Z → Can be any order
printf '\x1b[48;5;200mHello\x1b[0m' # Hello Background (in Pink)
printf '\x1b[255;0;0mHello\x1b[0m' # Hello (in Red)
Print console color string in Haskell
putStrLn "\x1b[38;5;200mHello\x1b[0m" -- Hello (in Red)
Print console color string in Java
// SEE: $j/AsciiColor.java
// WORK
System.out.println((char)27 + "[31mHello" + (char)27 + "[0m");
↑
+ -> Escape Sequence
System.out.println((char)27 + "[38;5;200mHello" + (char)27 + "[0m");
↑
+ -> Foreground (pink in FG)
System.out.println((char)27 + "[48;5;200mHello" + (char)27 + "[0m");
↑
+ -> Background (pink in BG)
// DOES NOT WORK
System.out.print("\033[0; 31m Hello \033[0;0m");
↑ ↑
| +-> Red
|
+-> Octal
// DOES NOT WORK
System.out.print("\u001b[0; 31m Hello \u001b[0;0m");
↑ ↑
| +-> Red
|
+-> Hex
Print console color string in C
printf("\x1b[0; 31m Hello \x1b[0;0m");
↑
+ -> Hex
Terminal Escape Sequence Code
\e → '\033' = Octal = 8 × 3 + 1 × 3 ⇒ 24 + 3 = 27 (Decimal) Escape Sequence In Shell
\x1b → '\x1b' = Hexadecimal = 16 × 1 + 1 × 11 ⇒ 16 + 11 = 27 (Decimal) Escape Sequence In Shell
+-> Shell Escape Sequence
↓
printf '\e[0; 31m Hello World \e[0;0m'
↑ ↑ ↑
| + -> Red |
| +-> Reset ESC_SEQ
+-> ESC_SEQ In Shell
printf '\033[0; 31m Hello World \033[0;0m'
↑ ↑ ↑
| + -> Red |
| +-> Reset ESC_SEQ
+-> ESC_SEQ In Octal
printf '\x1b[0; 31m Hello World \x1b[0;0m'
↑ ↑ ↑
| + -> Red |
| +-> Reset ESC_SEQ
+-> ESC_SEQ In Hexadicimal
What is \e ? where does it fit? Do we know somthing similar to \e ?, Yep
Name | decimal | octal | hex | C-Escape | Ctrl-Key | Description |
DEL | 7 | 007 | 0x07 | \a | ^G | Terminal bell |
BS | 8 | 010 | 0x08 | \b | ^H | Backspace |
HT | 9 | 011 | 0x09 | \t | ^I | Horizontal TAB |
LF | 10 | 012 | 0x0A | \n | ^J | Linefeed(newline) |
VT | 11 | 013 | 0x0B | \v | ^K | Vertical TAB |
FF | 12 | 014 | 0x0C | \f | ^L | Formfeed(New Page NP) |
CR | 13 | 015 | 0x0D | \r | ^M | Carriage return |
ESC | 27 | 033 | 0x1B | \e | ^[ | Escape character |
DEL | 127 | 177 | 0x7F | none | none | Delete character |
Console color string
# From $scr/AronLib.sh
# '\e[;' => '\033' = Octal = 8 x 3 + 1 x 3 => 24 + 3 = 27 (Decimal)
ESC_SEQ="\e[;"
All_reset="${ESC_SEQ}0m"
Bold_reset="${ESC_SEQ}21m"
Underline_reset="${ESC_SEQ}24m"
# Foreground colours
Black="${ESC_SEQ}30m"
Red="${ESC_SEQ}31m"
Green="${ESC_SEQ}32m"
Yellow="${ESC_SEQ}33m"
Blue="${ESC_SEQ}34m"
Magenta="${ESC_SEQ}35m"
Cyan="${ESC_SEQ}36m"
White="${ESC_SEQ}37m"
# br => Bright
Black_br="${ESC_SEQ}90m"
Red_br="${ESC_SEQ}91m"
Green_br="${ESC_SEQ}92m"
Yellow_br="${ESC_SEQ}93m"
Blue_br="${ESC_SEQ}94m"
Magenta_br="${ESC_SEQ}95m"
Cyan_br="${ESC_SEQ}96m"
White_br="${ESC_SEQ}97m"
# Background colours (optional)
Black_bg="${ESC_SEQ}40m"
Red_bg="${ESC_SEQ}41m"
Green_bg="${ESC_SEQ}42m"
Yellow_bg="${ESC_SEQ}43m"
Blue_bg="${ESC_SEQ}44m"
Magenta_bg="${ESC_SEQ}45m"
Cyan_bg="${ESC_SEQ}46m"
White_bg="${ESC_SEQ}47m"
Blink_bg="${ESC_SEQ}5m"
# Font styles
Reg_fs="${ESC_SEQ}0m"
Bold_fs="${ESC_SEQ}1m"
Underline_fs="${ESC_SEQ}4m"