binary

How does the binary DAT from Maxmind work?

Maxmind offers a binary DAT file format for downloading their GeoIP database. http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz Does anyone know how this has been packaged? Also, is there any kind of copy protection on the data? I'd like to offer up a set of data in a similar way. Anyone with any knowledge of thi...

Unescape/unquote binary strings in (extended) url encoding in python

Hi, for analysis I'd have to unescape URL-encoded binary strings (non-printable characters most likely). The strings sadly come in the extended URL-encoding form, e.g. "%u616f". I want to store them in a file that then contains the raw binary values, eg. 0x61 0x6f here. How do I get this into binary data in python? (urllib.unquote onl...

Adding binary checkbox values to MySQL database using PHP

I'm new to PHP, and I am creating a basic CMS using PHP and MySQL. I'm struggling to get the checkbox information from my HTML page across into the database. How can I make the values to appear as binary 0 or 1 values? The HTML document is written as follows: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w...

libpq send integer as binary

I have a libpq program that is routinely inserting numbers into a database. These numbers, which I'm expecting to grow quite large, are stored int the uint64_t type. I'm wanting to send the integer to libpq as binary, but Postgres won't be able to tell its unsigned. Is there a way to specify an unsigned integer in Postgres or libpq? ...

Reading binary data with seekg fails.

I'm trying to read binary data from a specific offset. I write the data in the following way: long RecordIO::writeRecord(Data *record) { this->openWrite(); fstream::pos_type offset = file->tellp(); file->write(reinterpret_cast<char*>(record), sizeof(Data)); return (long)offset; } The offset returned is stored, and re...

Converting list of integers into a binary "string" in python

I have a list of numbers that i would like to send out onto a socket connection as binary data. As an example, i start off with the following list: data = [2,25,0,0,ALPHA,0,23,18,188] In the above list, ALPHA can be any value between 1 and 999. Initially, I was converting this into a string using hexdata = ''.join([chr(item) for i...

How to reverse String To Binary

foreach (byte binaryOutupt in Encoding.ASCII.GetBytes(fileLine)) { fileOutput.Write(binaryOutupt.ToString("x2")); } I got this code which let me convert string byte to hex but how do I reverse this? ...

iPhone submission - The binary you uploaded was invalid

Hi there, Having gone through all the steps of submitting my app to the iStore by the book (and other manuals around), I get a 'not so funny' response after uploading my binary: 'The binary you uploaded was invalid. Fat binaries require a MinimumOSVersion of at least 3.0' Now, I set the device deplyment to be 2.2.1 and the Base SDK th...

Help me understand why page sizes are a power of 2?

Answer I need help with is: Recall that paging is implemented by breaking up an address into a page and offset number. It is most efficient to break the address into X page bits and Y offset bits, rather than perform arithmetic on the address to calculate the page number and offset. Because each bit position represents...

How can I read an unsigned int from a binary file in Perl?

Lets say I have a binary file that is formatted like [unsigned int(length of text)][text][unsigned int(length of text)][text][unsigned int(length of text)][text] and that pattern for the file just keeps repeating. How in Perl do I read the unsigned int and print it out followed by the text block? Again, this is a binary file and not ...

C# Howto convert image to binary?

I have an image (.png) and I want this picture to convert to binary. How can I do this? I am using Webforms ASP.NET C# ...

View binary image assembly

I have a binary image (a dll) which I wish to view the assembly for. I also have the PDB associated with the dll. Are there any tools out there that will allow me to open the binary image and navigate through the assembly, without needing to execute it? ...

PHP Compression Options

I need to compress some binary files as quickly as possible with PHP - it needs to be reasonably fast and easy to use. What options can you fantastic people recommend? :) Jamie ...

Serialize a C# class to binary be used by C++. How to handle alignment?

I am currently serializing a C# class into a binary stream using BinaryWriter. I take each element of the class and write it out using BinaryWriter. This worked fine as the C++ application reading this binary file supported packed structs and hence the binary file could be loaded directly. Now I have got a request to handle alignment ...

Serving file download with python

Hey gang, I'm trying to convert a legacy php script over to python and not having much luck. The intent of the script is to serve up a file while concealing it's origin. Here's what's working in php: <?php $filepath = "foo.mp3"; $filesize = filesize($filepath); header("Pragma: no-cache"); header("Expires: 0"); header("Cache-Control:...

Designing a BitStream in C#

I'm looking at the C# library called BitStream, which allows you to write and read any number of bits to a standard C# Stream object. I noticed what seemed to me a strange design decision: When adding bits to an empty byte, the bits are added to the MSB of the byte. For example: var s = new BitStream(); s.Write(true); Debug.Assert(s.To...

How expensive is gluing binaries (list_to_binary)?

One process listen to server on async socket and on each message {tcp, Socket, Bin} takes it's buffer and: Data = list_to_binary([Buffer, Bin]), {next_state, 'READY', State#state{buffer = Data}}. On some events it flushes buffer: 'READY'({flush}, #state{buffer = Buffer} = State) -> {reply, {Buffer}, 'READY', State#state{buffer = <<>...

writing binary data

Hello, I am writing to binary file using fstream and when open the file using binary flag. I needed to write some text as binary, which a simple write did the trick. The problem is that I need also to write (as shown in hexadecimal) 0. The value when opened in binary notepad is shown zero, but when tried to write this the value not zer...

Serialize JavaScript data structures for SQLite

My goal is to serialize JavaScript native datatypes for storage into an SQLite database. I'm doing this within a Firefox extension, and so I have access to the Mozilla platform XPCOM api. Initially I was thinking that the easiest thing to do would be to just store JSON strings. However, if there is a way to serialize native datatypes w...

Using binary flags to represent states, options, etc

If I wanted to represent states or options or something similar using binary "flags" so that I could pass them and store them to an object like OPTION1 | OPTION2 where OPTION1 is 0001 and OPTION2 is 0010, so that what gets passed is 0011, representing a mix of the options. How would I do this in C++? I was thinking something like enum ...