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
4
votes
3 answers

Which encoding to use for reading a string from a file?

I'm parsing a file (which I don't generate) that contains a string. The string is always preceded by 2 bytes which tell me the length of the string that follows. For example: 05 00 53 70 6F 72 74 would be: Sport Using a C# BinaryReader, I read the…
Bridgey
  • 529
  • 5
  • 15
4
votes
1 answer

Tricky pattern matching of a binary string in Erlang

I am using Erlang to send message between an email server and Spamassassin. What I want to achieve is retrieving the tests done by SA to generate a report (I am doing some kind of mail-tester program) When SpamAssassin answers (through raw TCP) it…
lambda79
  • 45
  • 5
4
votes
3 answers

Create and Download PDF file from binary string with JS/TS

An Axios request to server response the content of a PDF as a binary string. export const fetchPDFfile = async (id: string): Promise => { const { data } = await http.get(`${baseUrl}/${id}.pdf`); return data; }; The response in…
Amir-Mousavi
  • 4,273
  • 12
  • 70
  • 123
4
votes
4 answers

Converting python float to bytes

I want to convert a Python float into a byte array, encoding it as a 32 bit little-endian IEEE floating point number, in order to write it to a binary file. What is the modern Pythonic way to do that in Python 3? For ints I can do…
N. Virgo
  • 7,970
  • 11
  • 44
  • 65
4
votes
0 answers

React Native - 2D Barcode scanner input triggering android shortcuts

Currently I'm building an app with the react-native-keyevent package which is working fine and grabs the appropriate key events from a HID 2D HoneyWell barcode scanner. The issue is I've came across a barcode in PDF417 format with some encrypted…
4
votes
2 answers

PHP Curl returning inconsistent data for XML feed

I'm working on a XML reader and am running into a odd issue with a few feeds. Using CURL or even file_get_contents the feeds load as binary data more often than real data. Whenever I load the feed in a browser it looks fine. The specific feed is…
Jeff
  • 106
  • 1
  • 10
4
votes
1 answer

How to add two bytes together in Java, with wrap around if there is overflow

I need to add up all of the bytes in a byte array consisting of only ASCII characters using one's complement binary addition, storing the result as a single byte checksum. I am trying to start with the basics by figuring out how to add just 2 bytes…
4
votes
1 answer

Manually convert PostgreSQL binary format of timestamp to integer

I've read that PostgreSQL internally stores timestamps as an 8-byte/64-bit integer. To check this I've created a table, inserted some timestamps and queried the heap_page_items. The output e.g. for timestamp 2019-01-08 09:00:00 was 00 e4 c2 56 …
user35934
  • 374
  • 2
  • 13
4
votes
3 answers

How do you read binary data in C# .NET and then convert it to a string?

As opposed to using StreamReader/Filestream I want to read binary data from files and show that data (formatted) in a textbox.
liamzebedee
  • 14,010
  • 21
  • 72
  • 118
4
votes
3 answers

Meaning of character in C's streams

I seem to have a blind spot in my understand of the meaning of character in C's stream abstraction; I just can't seem to stitch the picture together. What is the meaning of character with respect to binary streams? From 7.19.7.1p2 ... If the…
zagortenay333
  • 259
  • 3
  • 8
4
votes
1 answer

How to receive floating point data over a websocket in typescript

I understand that there is no way to easily send and receive floats the same way there is for strings. However, if I setup my websocket like this: ws = new WebSocket(address); ws.binaryType = 'blob'; I should be able to convert the incoming…
Eben Kadile
  • 759
  • 4
  • 21
4
votes
2 answers

Search for most occurring patterns in a non language text file

I'm not completely sure this answer belongs here but I'm looking to find patterns into an ascii file. The file itself is composed of alphanumeric characters and I want to just check for repeating patterns in the file, disregarding of separators and…
Jorge Córdoba
  • 51,063
  • 11
  • 80
  • 130
4
votes
2 answers

R - generate all possible pairwise combinations of binary vectors

I am looking for a smart way to generate all pairwise combinations of two vectors of length n, where only one value is not zero. For now I am doing something quite desperate with loops through each combination with: n <- 3; z <- rep(0,n); m <-…
user971102
  • 3,005
  • 4
  • 30
  • 37
4
votes
0 answers

React Native split image into binary chunks

Is it possible in react native to split an image into binary chunks? If so what is the method of doing so. I am using the CameralRoll API to get filepaths to images on the user's phone. We want to upload images to our server in chunks using…
Thomas Charlesworth
  • 1,789
  • 5
  • 28
  • 53
4
votes
1 answer

Parsing Mixed Binary Data in C++

I have a blob of data I am parsing. It has mixed data types, some doubles followed by some floats. This is how I have gone about parsing out the doubles into a vector. I just want some feedback on if there is a better way to do this. I feel like…
gfree
  • 479
  • 7
  • 16