Files
kichikuou_xsystem35-sdl2/shell/text-decoder.ts
T
2017-03-25 13:31:02 +09:00

19 lines
512 B
TypeScript

class FallbackTextDecoder {
constructor(utfLabel?: string) {}
decode(buffer: DataView): string {
let out = '';
for (let i = 0; i < buffer.byteLength; i++) {
let c = buffer.getUint8(i);
if (c < 128)
out += String.fromCharCode(c);
else
out += '%' + c.toString(16);
}
return out;
}
}
if (!(<any>window).TextDecoder)
(<any>window).TextDecoder = <TextEncoding.TextDecoderStatic>FallbackTextDecoder;