7,821 questions
1
vote
1
answer
136
views
Why can't I return type byte in lambda expression in Arrays.setAll
I'm trying to implement a lambda function (for educational purposes) to initiate an array to append to the front of potentially encrypted data to save information like salt and initiation vector, ...
0
votes
1
answer
174
views
Split payload data from sensor into separate bytes length
Please I'm having an issue where I need to split a payload coming from an energy meter into chunks of 5-bytes each that represent different values of line parameters. The payload length is 35 bytes as ...
0
votes
2
answers
126
views
How to reverse the bytes of a number in Excel?
In an excel cell, I have a large number represented as a string, lets say 12345689994765411.
I am looking for a way to reverse the bytes inside that number to get the decimal representation of that ...
1
vote
2
answers
132
views
How can i convert a negative binary number to sbyte(c#)
I am messing around with c#, and i noticed something. If i were to instantiate an sbyte
with 8 bits, such as 0b_1111_1111 (-1), it throws an error, but if i were to first make a byte with it, and then ...
0
votes
1
answer
42
views
How to serialize protobuf message into a pre-allocated byte array with offset in c#? (Protobuf 3.32.0.0)
The methods AI showed me are not working. However, one method mentioned by AI seems to be usable, but it is private:
private CodedOutputStream(byte[] buffer, int offset, int length)
So, how can I ...
-5
votes
1
answer
80
views
Bytes type is required [closed]
I am getting the error message
data_new.write(binary_data[j])
TypeError: a bytes-like object is required, not 'int'
although binary_data should be bytes-like.
data_new = open(Datei_neu, "wb"...
0
votes
1
answer
118
views
C# String to literal bytes [duplicate]
I would like to extract text from a textbox and use it as a hexadecimal:
When someone types in "80" into the textbox, I want to be converted from string to hex "0x80", not "...
0
votes
0
answers
45
views
Comparing strings received as bytes
I'm running a python script that receives data over a TCP connection. This connection can send multiple messages that consists of multiple variables which have multiple data types. When a string is ...
0
votes
0
answers
48
views
How to write a string containing binary representation of data to file? [duplicate]
I am trying to write a binary string as binary data to file but my function seems to be having a problem with the int conversion. I am reading a text file and manipulating it which gives me a string ...
0
votes
0
answers
32
views
How to serialize mpf object to raw binary bytes or bytearray in python mpmath
I'm working on a python program that uses mpmath to implement the Chunovsky algorithm for computing pi. I want to make my program log its progress to a file on regular intervals, so that I can ...
0
votes
0
answers
48
views
Flutter Object Box store image from URL
Does anyone know how we can store images obtained from a URL to object box ?
This is what i currently have:
@Entity()
class ServiceModel {
@Id()
int id = 0;
@Unique()
final String identifier;
...
0
votes
2
answers
101
views
VB.net Hex to byte array translated to C#
Hey all I am getting the following error when running this code:
byte[] bytes = new[] {
Convert.ToByte("&H" + Conversion.Hex(127)),
Convert.ToByte("&H" + Conversion....
0
votes
1
answer
72
views
Decoding X32 Behringer mixer response
I would like help please to get the 4 Return meter values (post gain/trim, gate, dyn gain reduction and post‐fade) from the X32 behringer mixer, these are in 32 bits floats, little‐endian coded. to ...
3
votes
2
answers
170
views
Ruby pack and unpack hex value does not return the same value?
I have a hex string of unknown (variable) length and I want to pack or unpack at any time to convert to bytes.
["a"].pack("H*")
# => "\xA0"
I'm getting \xA0 -- is ...
-2
votes
1
answer
96
views
modifying items in byte[] arrays using loops (C#)
I got a byte[] array from an input file (ASCII text file) and I'm trying to delete all bytes of a pre-set hex value, without converting the array to string and without using lists.
This is the code I ...
1
vote
3
answers
148
views
signed int and unsigned int are equal based on bytes. but not signed char and unsigned char
Consider the following code:
signed a = -1;
unsigned b = UINT_MAX;
printf("%d\n", a==b);
signed char c = -1;
unsigned char d = UCHAR_MAX;
printf("%d\n", c==d);
The result will be:...
2
votes
1
answer
267
views
Reading C struct dumped into a file into Python Dataclass
Is there a consistent way of reading a c struct from a file back into a Python Dataclass?
E.g.
I have this c struct
struct boh {
uint32_t a;
int8_t b;
boolean c;
};
And I want to read it's data ...
-2
votes
1
answer
57
views
Why does hex give a different output than indexing into bytes in python?
I'm trying to confirm this struct is being formatted correctly for network byte order, but printing out the bytes and printing out the hex of the bytes give me different output, with the hex being the ...
1
vote
1
answer
551
views
The from_utf8 Rust function cannot read some ASCII strings (invalid utf-8 sequence of 1 bytes)
I am trying to convert a vector of ASCII bytes into a rust string. I found the std::str::from_utf8() function, that should be able to handle all ASCII strings. For some reason it cannot read the ...
-2
votes
1
answer
213
views
bytes().nth() vs chars().nth() in rust
I recently found out that bytes.nth(i) is waay faster than chars.nth(i) if you want to iterate over a String.
pub fn test(word1: String) {
for i in (0..word1.len()).rev() {
word1.bytes()....
1
vote
3
answers
338
views
Handling byte strings in robot framework returns in null or blank
I have results returned from a function and storing it in a dictionary like this
${results}={'value': b'\x01\x00\x01\x00\x01\x00', 'type': None, 'error': None}
Now I want to extract only the value of ...
3
votes
1
answer
99
views
Handling multiple byte lengths within a WAV struct
I'm writing a .wav PCM file header in C, but one part I'm still stumped on handling is the bits per sample format parameter of a file. Right now I've only added support for 8-bit and 16-bit PCMs (...
4
votes
2
answers
251
views
Byte functions in Visual Basic
Why does the VB expression
Asc(ChrB(128) & ChrB(0))
yield 63 and not 128?
Recently, I've been looking at Visual Basic's InputB function for reading binary data. According to the help system, ...
0
votes
3
answers
111
views
Binary integer representation printing in Linux / Shell
I have a Python scripts for printing a decimal string-represented integer as a 4-bytes little-endian representation:
import sys
i4 = int(sys.argv[1])
sys.stdout.buffer.write(i4.to_bytes(4, 'little'))
#...
1
vote
2
answers
295
views
About the use of uint8_t in C when counting
I wanted to make sure that I understood what is happening in the following code:
#include <stdio.h>
#include <stdint.h>
int main (void)
{
uint8_t a = 255;
a = a + 5;
printf(&...