Escaping for special characters
There are some instances where I want to use escape characters. But sometimes, I don't know how. So let me clear things out on this post. Note that these characters are tested in Java.
Newline: \n (ASCII/Unicode 10)
Carriage return: \r (ASCII/Unicode 13)
Tab: \t (ASCII/Unicode 9)
Single quote: \'
Double quote: \"
Backtick: \`
Dollar sign: \$
Backslash: \\
(Above are pretty much expected what is going to happen)
Double quote: \"
Backtick: \`
Dollar sign: \$
Backslash: \\
(Above are pretty much expected what is going to happen)
Hexadecimal number: \uXXXX (in java or javascript, syntax to use hexadecimal number is 0xXXX... and the console will output the number in decimal number.)
NULL character: \0 (ASCII/Unicode 0). NULL Character is especially important when it comes to C programming; Null Character is used to define the end of a String literal, since there is no String class.
Ex.
char[5] test;
test[0] = 't';
test[1] = 'e';
test[2] = 's';
test[3] = '\0';
test[4] = 't';
printf("this is a %s", test);
will only print "tes" because \0 marks the end of a string.
Ex.
char[5] test;
test[0] = 't';
test[1] = 'e';
test[2] = 's';
test[3] = '\0';
test[4] = 't';
printf("this is a %s", test);
will only print "tes" because \0 marks the end of a string.
Vertical tab: \v (ASCII/Unicode 11). Java gives a syntax error when I do \v. Why?? and why does it not work? found an answer from stackoverflow(https://stackoverflow.com/questions/3380538/what-is-a-vertical-tab):
Vertical tab was used to speed up printer vertical movement. Some printers used special tab belts with various tab spots. This helped align content on forms. VT to header space, fill in header, VT to body area, fill in lines, VT to form footer. Generally it was coded in the program as a character constant. From the keyboard, it would be CTRL-K.I don't believe anyone would have a reason to use it any more. Most forms are generated in a printer control language like postscript.
Vertical tab was used to speed up printer vertical movement. Some printers used special tab belts with various tab spots. This helped align content on forms. VT to header space, fill in header, VT to body area, fill in lines, VT to form footer. Generally it was coded in the program as a character constant. From the keyboard, it would be CTRL-K.I don't believe anyone would have a reason to use it any more. Most forms are generated in a printer control language like postscript.
Backspace: \b (ASCII/Unicode 8)
Form feed: \f (ASCII/Unicode 12)
This was not really working on sublime build, so I went onto the terminal to test. But it showed a weird result, making some kind of tab only:
So I again went to stackoverflow to check it out:
12 (form feed, \f, ^L), to cause a printer to eject paper to the top of the next page, or a video terminal to clear the screen. It seems that this symbol is rather obsolete now and the way it is processed may be(?) implementation dependent.
(.. and)
If you were programming for a 1980s-style printer, it would eject the paper and start a new page. You are virtually certain to never need it.
12 (form feed, \f, ^L), to cause a printer to eject paper to the top of the next page, or a video terminal to clear the screen. It seems that this symbol is rather obsolete now and the way it is processed may be(?) implementation dependent.
(.. and)
If you were programming for a 1980s-style printer, it would eject the paper and start a new page. You are virtually certain to never need it.