I'm currently using a piped input/output stream principe to read from and write to a shell channel using JSCH.
Problem: I'm getting weird characters in my jQuery terminal when I transport the response of the shell to jQuery terminal.
Weird characters (jQuery terminal):
I tried reading the piped input stream in different ways to solve the problem:
Try 1:
private synchronized String readResponse() throws IOException {
byte[] array = new byte[pin.available()];
pin.read(array);
return new String(array, Charset.forName("UTF-8"));
}
Try 2:
private synchronized String readResponse() throws IOException {
final StringBuilder s = new StringBuilder();
while(pin.available() > 0) {
s.append((char) pin.read());
}
return s.toString();
}
Sadly this problem still persist. Can anyone help me?
Update: I just found out that, when I print the same string in my Java output console, it works.
Update 2: I've imported the unix_formatting.js file and it's almost fixed. The thing with this file is that it has limited support for unix escape codes. Link to js: https://unpkg.com/jquery.terminal@1.23.2/js/unix_formatting.js
How can I fix this problem in jQuery terminal?