What are all the escape characters?

JavaStringEscaping

Java Problem Overview


I know some of the escape characters in Java, e.g.

\n : Newline
\r : Carriage return
\t : Tab
\\ : Backslash
...

Is there a complete list somewhere?

Java Solutions


Solution 1 - Java

You can find the full list here.

  • \t Insert a tab in the text at this point.
  • \b Insert a backspace in the text at this point.
  • \n Insert a newline in the text at this point.
  • \r Insert a carriage return in the text at this point.
  • \f Insert a formfeed in the text at this point.
  • \' Insert a single quote character in the text at this point.
  • \" Insert a double quote character in the text at this point.
  • \\ Insert a backslash character in the text at this point.

Solution 2 - Java

Java Escape Sequences:

\u{0000-FFFF}  /* Unicode [Basic Multilingual Plane only, see below] hex value 
                  does not handle unicode values higher than 0xFFFF (65535),
                  the high surrogate has to be separate: \uD852\uDF62
                  Four hex characters only (no variable width) */
\b             /* \u0008: backspace (BS) */
\t             /* \u0009: horizontal tab (HT) */
\n             /* \u000a: linefeed (LF) */
\f             /* \u000c: form feed (FF) */
\r             /* \u000d: carriage return (CR) */
\"             /* \u0022: double quote (") */
\'             /* \u0027: single quote (') */
\\             /* \u005c: backslash (\) */
\{0-377}       /* \u0000 to \u00ff: from octal value 
                  1 to 3 octal digits (variable width) */

The Basic Multilingual Plane is the unicode values from 0x0000 - 0xFFFF (0 - 65535). Additional planes can only be specified in Java by multiple characters: the egyptian heiroglyph A054 (laying down dude) is U+1303F / 𓀿 and would have to be broken into "\uD80C\uDC3F" (UTF-16) for Java strings. Some other languages support higher planes with "\U0001303F".

Solution 3 - Java

Yes, below is a link of docs.Oracle where you can find complete list of escape characters in Java.

Escape characters are always preceded with "" and used to perform some specific task like go to next line etc.

For more Details on Escape Character Refer following link:

https://docs.oracle.com/javase/tutorial/java/data/characters.html

Solution 4 - Java

These are escape characters which are used to manipulate string.

\t	Insert a tab in the text at this point.
\b	Insert a backspace in the text at this point.
\n	Insert a newline in the text at this point.
\r	Insert a carriage return in the text at this point.
\f	Insert a form feed in the text at this point.
\'	Insert a single quote character in the text at this point.
\"	Insert a double quote character in the text at this point.
\\	Insert a backslash character in the text at this point.

Read more about them from here.

http://docs.oracle.com/javase/tutorial/java/data/characters.html

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionizbView Question on Stackoverflow
Solution 1 - JavartpersonView Answer on Stackoverflow
Solution 2 - JavaEhrykView Answer on Stackoverflow
Solution 3 - Javamanisha mulchandaniView Answer on Stackoverflow
Solution 4 - JavaHeminView Answer on Stackoverflow