java "\u001B[J" 代表什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13801273/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 14:01:43  来源:igfitidea点击:

What does "\u001B[J" represent?

java

提问by Baz

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.

谁能向我解释一下字符串中的 \u001B[J 可能代表什么?我正在将输入字节流转换为 ascii 字符串。也许流采用其他编码。

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());

回答by paxdiablo

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

即 Unicode 1BESC字符),后跟两个字符[J,这是许多终端上常见的 ANSI 转义序列。

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

那个特别的人清除了屏幕。其他可以在这里找到。

回答by Baz

\u001B[J

means unicode

表示 Unicode

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

Unicode是存储在2个字节,所以后\ u是4倍六字节存在,在这种情况下是\u001B[J从其他