Skip to content

Commit

Permalink
Clean up some code in the Telnet control
Browse files Browse the repository at this point in the history
  • Loading branch information
NI committed Sep 17, 2019
1 parent cd88e06 commit 683c643
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions ui/control/telnet.js
Expand Up @@ -336,9 +336,15 @@ class Control {
this.charset = data.charset;

if (this.charset === "utf-8") {
let enc = new TextEncoder();

this.charsetDecoder = d => {
return d;
};

this.charsetEncoder = dStr => {
return enc.encode(dStr);
};
} else {
let dec = new TextDecoder(this.charset),
enc = new TextEncoder();
Expand All @@ -350,6 +356,10 @@ class Control {
})
);
};

this.charsetEncoder = dStr => {
return iconv.encode(dStr, this.charset);
};
}

this.sender = data.send;
Expand Down Expand Up @@ -453,13 +463,7 @@ class Control {
}

let currentLen = 0;
let enc = null;

if (this.charset !== "utf-8") {
enc = new iconv.encode(data, this.charset);
} else {
enc = new TextEncoder().encode(data);
}
const enc = this.charsetEncoder(data);

while (currentLen < enc.length) {
const iacPos = this.searchNextIAC(currentLen, enc);
Expand Down

0 comments on commit 683c643

Please sign in to comment.