Foo
Foo

Reputation: 4606

What form of encoding do you type into System.out.println in Java?

I am trying to learn encoding, so please bear with me.

Using an online encoding tool such as this one, I can see that the data

a
b

can be represented

in Ascii/ANSI as:

a
b

in Hex as:

610d0a62

in base64 as:

YQ0KYg==

But in Java if I need to print this data to the screen I need to use the command

System.out.println("a\r\nb");

What form of encoding is \r\n?

In other words, is it fair to say that \r\n is the keyboard representation for the ascii

a
b

Upvotes: 1

Views: 68

Answers (1)

Jack
Jack

Reputation: 133587

It's not a real encoding, is an escape character + a character.

It is used to define common ASCII characters which are not printable. The list available to Java is here.

Basically \r is interpreted as the value 0x0D or 13 in decimal, which is the carriage return.

Upvotes: 1

Related Questions