20

Can anyone explain to me what \u001B[J within a string might represent? I'm converting an input byte stream to an ascii string. Perhaps the stream is in some other encoding.

UPDATE:

This is how I read the stream

inputStreamReader = new InputStreamReader(session.getStdout(), "ASCII");

int length = inputStreamReader.read(buffer);
stringBuilder.append(buffer, 0, length);

// LOG the result
StringEscapeUtils.escapeJava(stringBuilder.toString());
Baz
  • 12,713
  • 38
  • 145
  • 268

2 Answers2

38

That is Unicode 1B (the ESC character), followed by the two characters [ and J, an ANSI escape sequence common on many terminals.

That particular one clears the screen. Others can be found here.

paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953
1
\u001B[J

means unicode

Unicode is stored in 2 bytes, so after \u there is 4x hexa bytes, in this case is \u001B The [J is from other