Skip to content

Commit

Permalink
Use libapps utf8 decoder
Browse files Browse the repository at this point in the history
  • Loading branch information
yudai committed Aug 23, 2017
1 parent 248f51b commit ba1aa69
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 39 deletions.
62 changes: 31 additions & 31 deletions js/dist/gotty-bundle.js

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions js/src/webtty.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { lib } from "libapps"

export const protocols = ["webtty"];

export const msgInputUnknown = '0';
Expand Down Expand Up @@ -62,6 +64,8 @@ export class WebTTY {
let pingTimer: number;
let reconnectTimeout: number;

const decoder = new lib.UTF8Decoder()

const setup = () => {
connection.onOpen(() => {
const termInfo = this.term.info();
Expand Down Expand Up @@ -104,11 +108,7 @@ export class WebTTY {
const payload = data.slice(1);
switch (data[0]) {
case msgOutput:
this.term.output(
decodeURIComponent(Array.prototype.map.call(atob(payload), function(c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
}).join(''))
);
this.term.output(decoder.decode(atob(payload)));
break;
case msgPong:
break;
Expand Down
4 changes: 4 additions & 0 deletions js/typings/libapps/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,8 @@ export declare namespace lib {
export var Storage: {
Memory: Memory
}

export class UTF8Decoder {
decode(str: string)
}
}
6 changes: 3 additions & 3 deletions server/asset.go

Large diffs are not rendered by default.

0 comments on commit ba1aa69

Please sign in to comment.