mirror of
https://github.com/kichikuou/xsystem35-sdl2.git
synced 2026-09-22 22:48:08 +03:00
19 lines
512 B
TypeScript
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;
|