Add a fallback for TextDecoder

This commit is contained in:
kichikuou
2017-03-09 14:42:41 +09:00
parent cc1782ad3a
commit 04cae28ee1
2 changed files with 20 additions and 0 deletions
+2
View File
@@ -1,3 +1,5 @@
importScripts('text-decoder.js');
class ISO9660FileSystem {
private pvd: PVD;
+18
View File
@@ -0,0 +1,18 @@
class FallbackTextDecoder {
constructor(utfLabel?: string) {}
decode(buffer: DataView): string {
var out = '';
for (var 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>self).TextDecoder)
(<any>self).TextDecoder = <TextEncoding.TextDecoderStatic>FallbackTextDecoder;