本文整理了Java中org.jline.terminal.Terminal.encoding()
方法的一些代码示例,展示了Terminal.encoding()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Terminal.encoding()
方法的具体详情如下:
包路径:org.jline.terminal.Terminal
类名称:Terminal
方法名:encoding
[英]Returns the Charset that should be used to encode characters for #input() and #output().
[中]返回应用于对#input()和#output()的字符进行编码的字符集。
代码示例来源:origin: org.apache.karaf.shell/org.apache.karaf.shell.core
@Override
public Charset encoding() {
return terminal.encoding();
}
代码示例来源:origin: apache/karaf
@Override
public Charset encoding() {
return terminal.encoding();
}
代码示例来源:origin: apache/karaf
private Charset getEncoding(PrintStream ps) {
if (ps.getClass() == ThreadPrintStream.class) {
try {
return ((Terminal) Job.Utils.current().session().get(".jline.terminal")).encoding();
} catch (Throwable t) {
// ignore
}
try {
ps = (PrintStream) ps.getClass().getMethod("getCurrent").invoke(ps);
} catch (Throwable t) {
// ignore
}
}
try {
Field f = ps.getClass().getDeclaredField("charOut");
f.setAccessible(true);
OutputStreamWriter osw = (OutputStreamWriter) f.get(ps);
return Charset.forName(osw.getEncoding());
} catch (Throwable t) {
// ignore
}
return null;
}
代码示例来源:origin: org.apache.karaf.shell/org.apache.karaf.shell.core
private Charset getEncoding(PrintStream ps) {
if (ps.getClass() == ThreadPrintStream.class) {
try {
return ((Terminal) Job.Utils.current().session().get(".jline.terminal")).encoding();
} catch (Throwable t) {
// ignore
}
try {
ps = (PrintStream) ps.getClass().getMethod("getCurrent").invoke(ps);
} catch (Throwable t) {
// ignore
}
}
try {
Field f = ps.getClass().getDeclaredField("charOut");
f.setAccessible(true);
OutputStreamWriter osw = (OutputStreamWriter) f.get(ps);
return Charset.forName(osw.getEncoding());
} catch (Throwable t) {
// ignore
}
return null;
}
代码示例来源:origin: org.jline/jline
private static int readExt(Terminal terminal) {
try {
// The coordinates are encoded in UTF-8, so if that's not the input encoding,
// we need to get around
int c;
if (terminal.encoding() != StandardCharsets.UTF_8) {
c = new InputStreamReader(terminal.input(), StandardCharsets.UTF_8).read();
} else {
c = terminal.reader().read();
}
if (c < 0) {
throw new EOFException();
}
return c;
} catch (IOException e) {
throw new IOError(e);
}
}
内容来源于网络,如有侵权,请联系作者删除!