Allowing user to customly setup server charset when connecting to a Telnet host

This commit is contained in:
NI
2019-09-14 15:20:50 +08:00
parent 25b595b5b6
commit 6b5c444f45
5 changed files with 153 additions and 9 deletions

View File

@@ -316,6 +316,23 @@ class Control {
this.colorM = color;
this.colors = this.colorM.get();
if (!data.charset || data.charset === "utf-8") {
this.charsetDecoder = d => {
return d;
};
} else {
let dec = new TextDecoder(data.charset),
enc = new TextEncoder();
this.charsetDecoder = d => {
return enc.encode(
dec.decode(d, {
stream: true
})
);
};
}
this.sender = data.send;
this.closer = data.close;
this.closed = false;
@@ -332,7 +349,7 @@ class Control {
this.parser = new Parser(
this.sender,
d => {
self.subs.resolve(d);
self.subs.resolve(this.charsetDecoder(d));
},
{
setEcho(newVal) {