binary

Format vs Language

Elsewhere on the SO universe a storm has been raging for a some time now. On whether humans should prefer something they can read vis-a-vis something they can't. Which made me take my thinking hat out after a long hiatus and pose a question for the enlightened: When do formats evolve into a domain specific language? Or, how do I deci...

What is the best way to download image data from ASP.NET to iphone?

I am building an iphone app that will require downloading an image from an ASP.NET web application (either as part of an XML document that is formatted according to the property list schema or by itself) into an (NSData *) object. What encoder should I use on the server side to generate compatible XML for the iphone? Is it as simple as...

Get bools out of byte and the other way

Simple question: How do i tell which bits in the byte are set to 0 and which are set to 1 for example: //That code would obviously wont work, but how do i make something similar that would work? byte myByte = 0X32; foreach(bool bit in myByte) { Console.WriteLine(bit); } //Part 2 revert bool[] bits = new bool[8]; bits[0] = 0 bits[...

C# binary literals

Is there a way to write binary literals in C#, like prefixing hexadecimal with 0x? 0b doesn't work. If not, what is an easy way to do it? Some kind of string conversion? ...

C++ FILE readInt function? (from a binary file)

Is there a function for FILE (fopen?) that allows me to just read one int from a binary file? So far I'm trying this, but I'm getting some kind of error I can't see cause the program just crashes without telling me. void opentest() { FILE *fp = fopen("dqmapt.mp", "r"); int i = 0; int j = 0; int k = 0; int * buffer; ...

Which algorithm for extremely high non burst errors?

I have a binary stream that has a very high error rate. The error rate is 50% meaning each bit has a 50% chance of being flipped. The error does not occur in bursts and is completely random, so Reed–Solomon codes wouldn't work well. Which scheme or algorithm should I apply to the stream? I don't care about the overhead at all. This ...

Unexpected result from HttpURLConnection - reading remote binary file.

I'm trying to read a remote binary file (say, image) from internet like this: HttpURLConnection connection = (HttpURLConnection) myUrl.openConnection(); //myUrl - URL object pointing for some location if(connection.getResponseCode() == 200){ File temp = File.createTempFile("blabla", fileName); //fileName - string name of file Fi...

Ruby Integer to Binary string

I need to encrypt a integer, but all the crypto libraries only support strings. What is the proper method to convert a integer to a binary string in Ruby? (not '10111', I think that it's ASCII values) EDIT: I wasn't thinking about Rijndael as stream encryption. ...

Determining binary/text file type?

Namely, how would you tell an archive (jar/rar/etc.) file from a textual (xml/txt, encoding-independent) one? ...

Binary Data Vb6 to C#

Hi guys, I've a problem! I've a binary data that I know that is been created using Vb6, I want read all informations using C#. How Can I do this? I don't data structure of the file!!! Thanks for your attention ...

(Java) Specify number of bits (length) when converting binary number to string?

I'm trying to store a number as a binary string in an array but I need to specify how many bits to store it as. For example, if I need to store 0 with two bits I need a string "00". Or 1010 with 6 bits so "001010". Can anyone help? EDIT: Thanks guys, as I'm rubbish at maths/programming in general I've gone with the simplest solution w...

does adding new member function into d pointer class break binary compatibility?

Will adding new member function into d pointer class definition break binary compatibility? For example, will the new definition below break binary compatibility compared to the original? (side question, is there a tool that will tell me if a new .so breaks binary compatibility compared to the old .so? If not, how do I check manually?...

How can I modify specific part of a binary scalar in Perl?

I adopt select(), sysread(), syswrite() mechanism to handle socket messages where messages are sysread() into $buffer (binary) before they are syswritten. Now I want to change two bytes of the message, which denote the length of the whole message. At first, I use following code: my $msglen=substr($buffer,0,2); # Get the first two byte...

Is there a standard technique for packing binary data into a UTF-16 string?

(In .NET) I have arbitrary binary data stored in in a byte[] (an image, for example). Now, I need to store that data in a string (a "Comment" field of a legacy API). Is there a standard technique for packing this binary data into a string? By "packing" I mean that for any reasonably large and random data set, bytes.Length/2 is about t...

Writing a binary buffer to a file in python

Hi there, I have some python code that: Takes a BLOB from a database which is compressed. Calls an uncompression routine in C that uncompresses the data. Writes the uncompressed data to a file. It uses ctypes to call the C routine, which is in a shared library. This mostly works, except for the actual writing to the file. To uncomp...

Two's complement binary form

In a TC++ compiler, the binary representation of 5 is (00000000000000101). I know that negative numbers are stored as 2's complement, thus -5 in binary is (111111111111011). The most significant bit (sign bit) is 1 which tells that it is a negative number. So how does the compiler know that it is -5? If we interpret the binary value gi...

In Sql Server, how to convert binary strings to binary?

I have some data in string format that represents binary data (e.g. '0x0002'). Is there some function or trick where I can convert these from literal strings to binary? That is, I want '0x0002' to become 0x0002, and SELECT CAST('0x0002' AS BINARY(20)) obviously won't do that. I did come up with some painfully slow process that involve...

How to Convert NSInteger to a binary (string) value

I am trying to figure out how to convert an NSInteger, say 56, to an NSString that is a binary representation of the original (int) value. Perhaps someone knows a formatting technique that can accept 56 and return "111000" within Objective C. Thanks All. ...

VB.NET Assigning a binary constant

Is there a way to assign a binary value to a vb variable? All of the obvious choices don't work. I've tried prefixing with &B, appending with b but nothing seems to work. I'm not having much luck searching for it either. I don't NEED this for my application, but am rather, just curious so alternate solutions are not necessary. [Edit...

how can I read a binary file using VBA?

I have a binary file that resulted from a program written in Compaq Visual Fortran. How can I read specific lines and save them in an Excel sheet? ...