I am having trouble decompressing a string in JavaScript. There is an XML file that is saved to a database. Before it is saved it is compressed using SharpZipLib in a VB application.
I am currently writing a web application that receives the compressed string through a Web API using JSON. What I am trying to do is to decompress the string into its original XML format so it can be used on the client side. I am trying to do this using JavaScript but I have not come across a way to decompress the string.
Below is an example of the code that I am trying to use with ZLib.js.
var buf = new ArrayBuffer(graphic.length);
var bufView = new Uint8Array(buf);
for (var i = 0; i < graphic.length; i++) {
bufView[i] = graphic.charCodeAt(i);
}
var inflate = new Zlib.Inflate(compressed);
var plain = inflate.decompress();
I receive an error saying 'Error: unsupported compression method'.
I was able to use an example to compress and then decompress a string using ZLib.js successfully so I'm wondering is there a different compression method being used in SharpZipLib.
I have also tried using js-inflate.min.js to inflate the string but this only returns an empty string.
// using js-inflate.min.js
var uncompressed2 = JSInflate.inflate(graphic);
Is there a way to decompress a compressed string in JavaScript? Does SharpZipLib use Gzip or some other compression method that is causing the problem?