Questions tagged [binary-data]

Binary-data is information stored using a two character alphabet (typically written using 0 and 1)

Binary Data is information which is stored using a two character alphabet. For example, the number 42 could be stored as its base-2 representation: 101010.

In modern computers, almost all data is ultimately represented in binary form.

To be useful, the writer and reader of binary data must have a pre-agreed format (e.g. a file consisting of a 32-bit, two's compliment integer followed by three IEEE 754 floating point numbers).

The term is usually used to distinguish data stored in this way against data stored using a textual encoding. For example, the digits of 42 in base-10 (4 and 2) may be represented using ASCII as 00110100 and 00110010. Whether this is considered binary data or not depends on the task at hand; a chat client would consider messages as textual data, but the communication protocol it is built on may consider the same messages as arbitrary binary data.

1585 questions
5
votes
2 answers

jetty websockets send binary data (image)

I am trying to use Jetty 8.1.2 WebSockets to send some binary data (an image) to a javascript client. websockets java code: BufferedImage image = getTheImage(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ImageIO.write(image, "jpg",…
Alina Danila
  • 1,683
  • 1
  • 24
  • 60
5
votes
1 answer

`struct.unpack_from` doesn't work with `bytearray`?

Unpacking from strings works: >>> import struct >>> struct.unpack('>h', 'ab') (24930,) >>> struct.unpack_from('>h', 'zabx', 1) (24930,) but if its a bytearray: >>> struct.unpack_from('>h', bytearray('zabx'), 1) Traceback (most recent call last): …
SingleNegationElimination
  • 151,563
  • 33
  • 264
  • 304
5
votes
3 answers

HDF5 for data files written with fortran

The HDF5 data storage uses the C convention, i.e. if I am storing a matrix A(N,M,K) in a binary file, the fastest changing dimension of the stored data will have size N. Apparently when I use the Fortran wrapper of HDF5, HDF5 automatically…
Pradeep Kumar Jha
  • 877
  • 4
  • 15
  • 30
5
votes
3 answers

How do I specify where Xcode stores the compiled binaries?

I'm writing in C++11 and for some reason, I haven't been able to get gcc to compile it, so I've been using Xcode. However, I'm writing programs that take arguments from the command line, so I need to be able to run them from the shell. Right now,…
limp_chimp
  • 13,475
  • 17
  • 66
  • 105
5
votes
1 answer

How does pack() and unpack() work in Ruby

In Ruby why we need array Packing? How does directive help to do such packing? I ran some code in my console to see what and how directives looks like in Array packing.But the output is closely same with each directives. Then in core how they…
Arup Rakshit
  • 116,827
  • 30
  • 260
  • 317
5
votes
1 answer

Detect if .csv file is actually .xls (Excel) file

I'd like to detect if a user accidentally uploads an Excel file marked as .csv. Is there a standard binary footprint for xls files that would make this possible?
Rafael
  • 540
  • 4
  • 8
5
votes
2 answers

Are there any characters that are not allowed in localStorage?

I've been using localStorage to store some binary data in string format, and although the value is definitely set (alerting it immediately after setting, or even some time after setting, shows the correct value) it is lost when the page next…
Niet the Dark Absol
  • 320,036
  • 81
  • 464
  • 592
4
votes
1 answer

Unit testing a binary format reader in C

I am writing a C library that reads a binary file format. I don't control the binary format; it's produced by a proprietary data acquisition program and is relatively complicated. As it is one of my first forays into C programming and binary file…
yamad
  • 298
  • 3
  • 9
4
votes
2 answers

Postgres bytea column is returning string (char array) instead of byte array

I have been using C# to write a concrete provider implementation for our product for different databases. W/out getting into details, one of the columns is of byte array type (bytea in postgres - due to the preferences bytea was chosen over blob).…
Falcon
  • 650
  • 1
  • 8
  • 24
4
votes
3 answers

Translating a C binary data read function to Python

(I've edited this for clarity, and changed the actual question a bit based on EOL's answer) I'm trying to translate the following function in C to Python but failing miserably (see C code below). As I understand it, it takes four 1-byte chars…
user626998
4
votes
6 answers

Storing data packets in a database

Problem description: In my application, I have to present the contents of data packets with a certain format. An example: An example Any packed binary data, for example: 4 byte header, 4 byte type (type codes having pre-defined meanings), then…
Eli Bendersky
  • 263,248
  • 89
  • 350
  • 412
4
votes
1 answer

What is the fastest method to extract multiple numbers embedded in a 32 bit binary number in Matlab

I have a 32 bit number (uint32) that contains four numbers in the following manner: Var1 is in bits 32:31 Var2 is in bits 30:22 Var3 is in bits 21:13 Var4 is in bits 12:1 The following code works but I'd like to make it…
Tom Mozdzen
  • 338
  • 4
  • 16
4
votes
1 answer

Getting Binary Data from StandardOutput

I'm starting a process with code similar to that below: // some of the flags are not needed process.StartInfo.CreateNoWindow = true; process.StartInfo.ErrorDialog = false; process.StartInfo.UseShellExecute =…
Brian Hasden
  • 4,050
  • 2
  • 31
  • 37
4
votes
1 answer

Store Binary Data in QR Code (ZXING Java Library)

My Java program needs to send a binary payload via QR Code, but I can't get it to work. I have tried several QR Code libraries and many approaches, but all seem to have this problem. My current implementation uses ZXING. The problem is that all the…
Yurelle
  • 348
  • 2
  • 13
4
votes
4 answers

Reading Structure Binary Data in Python?

Are there any nice Python solutions like Ruby's BinData for reading user-defined binary file/stream formats? If not, then what's the preferred way to this in Python outside of just using the struct module? I have a binary file that stores "records"…
dj29
  • 161
  • 1
  • 5