1

I try to use an example shown here: zlib-decompression-client-side

but I am unable to use the sample shown on JSfidle: decompress byteArray

I downloaded pako.js but no success. I even tried to copy the code given about the sample: pako.js

but I keep getting an error.

var charData = [31, 139, 8, 0, 0, 0, 0, 0, 0, 3, 5, 193, 219, 13, 0, 16, 16, 4, 192, 86, 214, 151, 102, 52, 33, 110, 35, 66, 108, 226, 60, 218, 55, 147, 164, 238, 24, 173, 19, 143, 241, 18, 85, 27, 58, 203, 57, 46, 29, 25, 198, 34, 163, 193, 247, 106, 179, 134, 15, 50, 167, 173, 148, 48, 0, 0, 0];

var binData = new Uint8Array(charData);
** here I get error: Typed array constructor argument is invalid **

// Pako magic
var data = pako.inflate(binData);

// Convert gunzipped byteArray back to ascii string:
var strData = String.fromCharCode.apply(null, new Uint16Array(data));

// Output to console
alert(strData);

any help will be appreciated.

Community
  • 1
  • 1
Ori
  • 367
  • 3
  • 16

1 Answers1

0

Try this and see it helps

var binData = new Uint32Array(charData);
EugenSunic
  • 13,162
  • 13
  • 64
  • 86
  • It give the same error. remember that the exact same code is working on JSFidle – Ori Jan 11 '15 at 15:13
  • Please explain. I thought that is exactly what I did: left a comment below his answer – Ori Jan 11 '15 at 15:24