diff --git a/core/rfb.js b/core/rfb.js index 721358cd..8c44dfa4 100644 --- a/core/rfb.js +++ b/core/rfb.js @@ -874,10 +874,7 @@ export default class RFB extends EventTargetMixin { this.sentEventsCounter+=1; - let data = new Uint8Array(text.length); - for (let i = 0; i < text.length; i++) { - data[i] = text.charCodeAt(i); - } + let data = new TextEncoder().encode(text); let h = hashUInt8Array(data); // avoid resending the same data if larger than 64k @@ -2841,11 +2838,7 @@ export default class RFB extends EventTargetMixin { mimes.push(mime); if (mime == "text/plain") { - - //textdata = new TextDecoder().decode(data); - for (let i = 0; i < data.length; i++) { - textdata+=String.fromCharCode(data[i]); - } + textdata = new TextDecoder().decode(data); if ((textdata.length > 0) && "\0" === textdata.charAt(textdata.length - 1)) { textdata = textdata.slice(0, -1);