unpack

How to create a .BAT file to download and unpack a zip file?

How to create a .BAT file to download and unpack a zip file from HTTP server? We have links like http://example.com/folder.zip and absolute folder link like C:\Users\UserName\Some mixed Русский English Adress\ if files from zip exist in directory owerrite them. using only native windows (xp vista win7 etc) BAT functions and files. C...

Ruby - How to unpack a binary string into a normal string?

I'm opening a CSV file and reading values from it using File.open(filename). So I do something like this: my_file = File.open(filename) my_file.each_line do |line| line_array = line.split("\t") ratio = line_array[1] puts "#{ratio}" puts ratio.isutf8? end The issue I'm having is the values in line_array seem to be in a strange for...

Perl pack/unpack/shift

I've been having this problem in Perl for a few days now, and after scouring countless man pages, perldocs and googling too many search terms, hopefully someone here can help me out. I am given two strings which represent hex values, i.e. "FFFF", not the Perl hex number 0xFFFF. Given two of these strings, I wish to convert them to bina...

PHP: path / unpack 64bit int in 64bit architecture

Can anyone tell me why I get the following output on x64 architecture: $ php -r 'echo pow(2, 33) . "\n";print_r(unpack("Ivalue", pack("I", pow(2, 33))));' 8589934592 Array ( [value] => 0 ) It seems as though it can handle signed 64bit ints, but can't pack / unpack them. According to the docs: http://us3.php.net/pack, the size of ...

Python: Unpacking an inner nested tuple/list while still getting its index number

I am familiar with using enumerate(): >>> seq_flat = ('A', 'B', 'C') >>> for num, entry in enumerate(seq_flat): print num, entry 0 A 1 B 2 C I want to be able to do the same for a nested list: >>> seq_nested = (('A', 'Apple'), ('B', 'Boat'), ('C', 'Cat')) I can unpack it with: >>> for letter, word in seq_nested: pr...

What exactly "W" do in unpack function in Perl?

I couldn't understand what exactly "W" do. my $x = "this is my string"; print unpack("W",substr($x,0,1)); Prints: 116 my $x = "this is my string"; print unpack("W",$x); Still Prints: 116 ...

how to unpack these type of javascript files??

var n=this;eval((function(Q){for(var C in n){if(C.charCodeAt(((2.17E2,0xA3)<=(0x1C,0x239)?(18.,7):(41.,0x12E)))==(0x208<(0x3A,138.70E1)?(111.60E1,116):(12,0x25))&&C.charCodeAt((83.<(0x42,0xFD)?(14.69E2,5):(0xC9,111.)>=(15.5E1,0xC4)?(123,0x37):(0x1C,0xB1)))==(0x23B>(110,0x1B9)?(0x1D2,101):(0x2A,24))&&C.length==((0x1B5,0x236)<148?(0x21,nul...

Determine unknown data format of binary data in PHP

I have binary data with a mix of uint32 and null terminated strings. I know the size of an individual data set ( each set of data shares the same format ), but not the actual format. I've been using unpack to read the data with the following functions: function read_uint32( $fh ){ $return_value = fread($fh, 4 ); $return_value = un...

How do I yield a pre-unpacked list?

I have a list that is created within an itertools.groupby operation: def yield_unpacked_list(): for key, grp in itertools.groupby(something_to_groupby, key=lambda x: x[0]): subset_of_grp = list(item[2] for item in list(grp)) yield key, subset_of_grp If, for example, subset_of_grp turns out to be [1, 2, 3, 4] and [5...

Get timestamp from base64Binary in PHP

A webservice returns a timestamp field in base64Binary format. It looks like this in SOAP response: <a:TimeStamp>AAAAAAMpI9Q=</a:TimeStamp> PHP __soapCall, however, b64_decode()s that and I get a binary string looking like ')#▒'. How do I get actual timestamp out of this? I tried to unpack('L') it but it gives me Array([1] => 0) as a ...

How can I get the number of pack`ed items in Perl without actually unpacking?

I have a string of packed values which was created sequentially using something like: while (...) { ... $packed .= pack( 'L', $val ); } In another program, after I load $packed, I wish to find out how many values were actually packed. I know how to do that after unpacking: my @vals = unpack( 'L*', $packed ); print scalar(@vals); ...

When would you use unpack('h*' ...) or pack('h*' ...)?

In Perl, pack and unpack have two templates for converting bytes to/from hex: h    A hex string (low nybble first). H    A hex string (high nybble first). This is best clarified with an example: use 5.010; # so I can use say my $buf = "\x12\x34\x56\x78"; say unpack('H*', $buf); # prints 12345678 say unpack('h*', $buf); # prints...