Tuesday 15 April 2014

vb.net - zLib decompress from string not file to DeflateStream -



vb.net - zLib decompress from string not file to DeflateStream -

i've been trying 2 weeks uncompress user-defined txxx string mp3 id2,3 file.

000000b0789c6330377433d63534d575f3f737b570343767b02929ca2c4b2d4bcd2b29b6b301d376367989b9a976c519f9e50ace1989452536fa60019b924c20696800017a10ca461f2c6aa30fd58a61427e5e72aa42228a114666e6f88cd047721100d5923799

thanks dr. adler correct answer when converted values string.

i have tried both ms deflatestream , gzipstream no success.

every illustration see uses stream file. not using file, have above zlib code in both array or string variable.

gzipstream gives me 'no magic number' , deflatestream gives me 'block length not match complement'.

i read post: http://george.chiramattel.com/blog/2007/09/deflatestream-block-length-does-not-match.html

tried removing bytes head, no luck. (i read trazillions of articles sending string deflatestream 1 time again 'no luck'!

i have above string, how send deflatestream? i'd post 2 hundred different code examples tried silly.

the funny thing is, built webaudio cue marker editor in less 2 weeks , lastly thing have (my programme must marker positions programme has worst sound editor known man (they embedded them in mp3 (bad) reason). hence, wrote own alter sound cue marker save hours of frustration @ work. however, i'm not getting much sleep lately.

help me sleep, please.

you can utilize memorystream instead of filestream both streams:

imports system.io imports system.io.compression imports system.text module module1 function hexstringtobytes(s string) byte() if (s.length , 1) = 1 throw new argumentexception("string odd number of characters in length - must even.") end if dim bb new list(of byte) = 0 s.length - 1 step 2 bb.add(convert.tobyte(s.substring(i, 2), 16)) next homecoming bb.toarray() end function sub main() dim s = "000000b0789c6330377433d63534d575f3f737b570343767b02929ca2c4b2d4bcd2b29b6b301d376367989b9a976c519f9e50ace1989452536fa60019b924c20696800017a10ca461f2c6aa30fd58a61427e5e72aa42228a114666e6f88cd047721100d5923799" dim result string = "" ' trim off leading 0 bytes , skip 3 bytes 0xb0 0x78 0x9c dim buffer = hexstringtobytes(s).skipwhile(function(b) b = 0).skip(3).toarray() using ms new memorystream(buffer) using decompressedmemorystream new memorystream using decompressionstream new deflatestream(ms, compressionmode.decompress) decompressionstream.copyto(decompressedmemorystream) result = encoding.default.getstring((decompressedmemorystream.toarray())) end using end using end using console.writeline(result) console.readline() end sub end module

outputs:

71f3-15-foo58a77 <trivevents><event><name>show chart</name><time>10000000.000000</time></event><event><name>show 1 time a</name><time>26700000.000000</time></event></trivevents>

(there leading 0 byte.)

p.s. looks bit unusual there 71f3-15-foo58a77 letter os instead of zeros.

p.p.s. if compressed info base64 string instead of hex string, pack more info same space.

vb.net zlib deflatestream

No comments:

Post a Comment