Questions tagged [byte]
A unit of information usually corresponding to 8 bits. This term is also most often used to indicate the smallest addressable unit of storage on a digital system.
7,772
questions
1
vote
2
answers
41
views
split a ByteArray to multiple ByteArrays by a single byte
I'm new to Kotlin development and I'm trying to use kotlin standard functions like split,partition,chunked,windowed to solve this problem and understand them better
I have a ByteArray like this
[123, ...
0
votes
1
answer
31
views
Convert a byte stream from a smartmeter to a string
From a smartmeter I receive a bytestream via USB IR Sensor on a Raspberry PI like this:
CHAR = b'\x00\x86\x1b\x1b\x1b\x1b\x01\x01\x01\x01v\x05\x18\xe0\x99:b\x00b\x00rc\x01\x01v\x01\x01\x05\x08J\xdd\...
-1
votes
0
answers
71
views
converting hex string to bytes and sending it through serial (python)
I'm having trouble sending 6 hex values (example: 02 00 0a 51 03 60) as bytes through usb with python. I need this to open locks by sending commands to a control board by usb.
I've managed to get this ...
0
votes
1
answer
40
views
Check byte size for Javascript string
I want to do some byte checking for string using Javascript and for that I've the following code:
const byteSize = str => new Blob([str]).size;
This thing work for me.
For example
byteSize("...
0
votes
0
answers
37
views
How can I take the difference of two overlapping byte streams in Python?
I have an audio stream coming in from an API call which generated text-to-speech; I am currently generating overlapping chunks of consecutive texts and want to only write the difference between a ...
2
votes
0
answers
26
views
How does U16 function of pwn (CTF) library works?
I am trying to solve uni challenge in Python, the challenge is located in CTF server (using pwn library to connect). I can interact with the server by sending keys, for example: 1-help, 2-read info ...
0
votes
0
answers
39
views
How to parse the end header of a 7z file?
I am looking into parsing 7z files without using any packages - simply by reading the bytes and handling them with my own code. The 7z format is however very badly documented from what I can find.
I ...
0
votes
1
answer
45
views
How can I convert byte to fixed size (size = 8) bitArray
I want Convert Byte to fixed size (size = 8) bit array
Want Behavior:
var bits = GetBits(0x00); // returned [0,0,0,0,0,0,0,0]
bits = GetBits(0x01); // returned [1,0,0,0,0,0,0,0]
bits = GetBits(0x0A);...
-1
votes
1
answer
57
views
Arduino Serial Read Reading more than a byte
I'm having a problem reading serial bytes.
If I input A, the code outputs: This just in ... A.
It's correct, but the problem happens when I input more than 1 character.
Input: AAA
Output:
This just ...
0
votes
0
answers
27
views
how can i turn a list[bytes] into bytes and then back into list[bytes]
i have a class User:
class User:
def __init__(name: str):
self.name: str = name
self.data: list[bytes] = []
...
every item in the self.data variable contains different ...
0
votes
1
answer
28
views
Groovy: Convert Zip content bytes to string
I have these 2 classes:
Message class
MessageLog class
The first class Message, has a method getBody which can return an object that we can specify (as in the documentation), and the second class ...
0
votes
1
answer
66
views
Do I need to account for host machine's endianness when writing to my Buffer class?
I'm writing a Buffer class which simply holds bytes in C++. It's got the usual read and write methods for various types; 16, 32 and 64 bit integers, floats and doubles. I'm using this primarily for in-...
0
votes
0
answers
52
views
regular expression and bytes [duplicate]
I have a big string of bytes. I need to split it by some preamble.
The preamble contains four bytes. The first, second and fourth bytes are fixed, and the third byte is changeable. I want to split it ...
0
votes
0
answers
42
views
STM32 Usart Data Width
I am exchanging data with Stm32 via uart.
However, when exchanging data, I can only receive 255 pieces of data.
How can I increase the data size?
The problem occurs when the data size is larger than ...
-1
votes
2
answers
79
views
What is the best way to convert an array of bytes Java code to python?
I have tried several ways to convert this Java instruction to python, but I always get some error or wrong outputs. What is the correct way to do it?
String x = new String(new byte[]{(byte) 23353, (...
0
votes
0
answers
22
views
C# network data stream processing
When C# processes network data streams, the encoding of the data stream is often not fixed and may be unknown. If you want to replace a certain section of English letters in the data stream, such as ...
1
vote
1
answer
145
views
How do I wrap a byte string in a BytesIO object using Python?
I'm writing a script with the Pandas library that involves reading the contents of an excel file.
The line currently looks like this:
test = pd.read_excel(archive_contents['spreadsheet.xlsx'])
The ...
0
votes
1
answer
38
views
How HeapByteBuffer converts byte array to short
I have a java program, where I m trying to convert a byte array to short.
byte arr[] = {-1,-1};
int value = ByteBuffer.wrap(arr).order(ByteOrder.LITTLE_ENDIAN).getShort();
the value I get from above ...
0
votes
0
answers
95
views
SPOIL rootme TCP back to college challenge: sending the right result after converting it into bytes but I keep getting wrong answer
In this challenge, I have to read what the server is printing, extract 2 integer values val1 & val2, calculate the square root of val1 and multiply by val2 and send the result to the server.
I ...
0
votes
0
answers
12
views
Receiving corrupt data with pyserial [duplicate]
I've been trying to receive serial data using USB to RS422 device which is a 'MOXA UPort 1130' with baudrate of 115200, 8 bits of data, no parity and 1 stop bit from lattice ecp5u FPGA,. as you see ...
1
vote
1
answer
122
views
Convert Vec<u8> to Vec<{float}> in rust
I'm looking to pass a message through a channel. The message type is bytes::Bytes due to the implementation of the channel.
The message I want to send is about a vector of floats (Vec<{float}>) ...
1
vote
0
answers
89
views
Getting OPC UA array object values (Byte, UInt16) in python client
I am creating a python OPC UA client based on opcua-asyncio github (https://github.com/FreeOpcUa/opcua-asyncio) to read values in an instrument that has a server already set up.
My problem lies in ...
0
votes
1
answer
52
views
Rotating bits in a byte in Java
I am trying to implement right_encode found in the SHA 3 specifications. https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-185.pdf
enter image description here
The specific part I am ...
0
votes
1
answer
76
views
PIL.UnidentifiedImageError: cannot identify image file <_io.BytesIO object at 0x11020f880>
I am trying to upload images to s3 via API gateway and sending base64 encoded image's bytes data through API gateway's REST endpoint. Below is the python code that works if i hardcode the bytes data
...
0
votes
0
answers
9
views
TinyMCE jump to byte offset
Two or more users in different browsers are looking at the same doc within my thin client browser app in tinymce. Only one user is Active Editor.
As the active editor types, I periodically broadcast ...
1
vote
1
answer
93
views
Calculate Git file blob SHA (handle emojis etc.)
I am pushing files to GitHub using the javascript API. I'd like to avoid using up an API call (toward rate limit) if the file on GitHub is unchanged. Hitting the tree API to get the file's sha doesn't ...
1
vote
2
answers
317
views
Is there a way to initialize an array or slice of bytes to zeroes in Zig?
Apparently Zig used to provide this feature in an easy way, but it was removed in 6a5e61.
What is the recommended approach now for when such a behavior is needed? To manually iterate through the array/...
2
votes
1
answer
59
views
conversion of string to Bytearray in python
I have a string variable in this format:
var = "x14\x12\x13\x11\x69"
My challenge is to convert this string into bytearray to get exactly:
bytearray(b'\x14\x12\x13\x11\x69')
...
2
votes
0
answers
82
views
add watermark to video and image with input and output array bytes
I'm trying to add watermark to images and videos using ffmpeg. My files are stored on AWS S3, so they are byte arrays ([]byte).
I need my input and output to be in a byte array and not saved to disk.
...
0
votes
2
answers
106
views
What is a byte value (Assembly)
I'm new to assembly programming, my first homework is to make a program that reads a byte value, and displays it back to the screen. My problem is, I'm not sure what they mean by byte value. I know ...
0
votes
0
answers
51
views
converting float (32 bit) and double (64 bit) to bytes
I am trying to send a data buffer from Python over TCP to a C++ server.
The TCP pack order is defined as follows:
bytes[0 till 3] must be an integer (32 bit) with value = length of the buffer
bytes[4 ...
0
votes
1
answer
49
views
Python Error TypeError: 'bytes' object cannot be interpreted as an integer when concatenating bytes
Here's my code:
with open("SomeFile", mode="rb") as file:
byte = file.read(1)
count = 0
previous = []
while byte != b"":
if len(previous) >= 2:...
-2
votes
1
answer
51
views
java read binary input as 49,48
I am getting this input 10010011 00000001
with:
byte[] binaryInput = new byte[1024];
int bytesReadinput = System.in.read(binaryInput);
// Create a ByteArrayInputStream object for the binary input.
...
0
votes
1
answer
60
views
How do I create a sliding window of 5 bits in a single byte?
Here is a visual of what I want to have happen 5 bit sliding window
In words, I want a sliding window of 5 bits. I need to store a history of 5 events within a single byte. I'm using the 5 most ...
0
votes
1
answer
34
views
Prevent addition of a BOM to UTF-8 SecureCRT session logged files
SecureCRT appears to be adding a BOM to all session logged files no matter what character encoding is selected. When UTF-8 is used, SecureCRT generates a UTF-8 with BOM file rather than a simple UTF-...
3
votes
1
answer
79
views
Determining how many Bytes is in a CSV row in Golang
I have a test.csv that I would line to read line by line and determine how many bytes are in each row.
This should be 37 bytes below as I am on Windows and first two rows have \r\n adding 4 total ...
0
votes
2
answers
86
views
KOTLIN - How to represent message length as 2 binary bytes
I am facing a problem while building an integration between ECR (electronic cash register) and an android POS. I'm working on the android POS and i want to calculate the message size and add it in &...
1
vote
1
answer
107
views
Idiomatic way to iterate over a string and replace value in original string with mapped value [duplicate]
I have a working solution on iterating over a string and mapping the rune to a mapping
package main
import (
"fmt"
)
func main() {
numToString := map[rune]string{
'0': &...
0
votes
1
answer
50
views
Change '\\' to '\' in bytes object type in python
I am confused with the usage of the bytes object type in Python. I am reading a Txt file that comprises 4 bytes of hex values in each row. For example one of my rows consists of hex values 81c50400. I ...
-1
votes
2
answers
69
views
Java: String vs StringWriter?
If I have an array of bytes(which could be from fairly large file), which is better for constructing a String?
new String(byteArr, UTF_8);
vs
try (final ByteArrayInputStream decompressed = new ...
0
votes
0
answers
61
views
fastapi websocket recieve_bytes and processes the bytes to a temporary audio file
IDK How to process bytes data from the data variable to make a temporary audio file to be processed into speech_recognition
@router.websocket('/change-voice/{speakerId}/{bahasaYangDigunakan}')
async ...
0
votes
0
answers
8
views
Byte array conversion clarification? [duplicate]
I am trying to create byte array of three bytes.
data = 0xee55
bi = bytearray(3)
bi[0] = 0x01 # register for speed
bi[1] = data & 0xFF # first byte of speed data
bi[2] = (data >> 8) & ...
0
votes
2
answers
67
views
Performance Issue with List<byte>
I have a file (~30MB) which I read with File.ReadAllBytes()
This File has a lot of structed data with different length (no terminator in between). So I have to check the length of the first data, cut ...
0
votes
0
answers
21
views
Display PDF doesn't work with Byte[] attribute, in context Angular, spring and S3 application
Good morning,
I use Angular, Spring and AWS S3 for an application in which I display png, jpg, pdf files...
I retrieve an Object from the backend which contains a Byte[], however I want to display a ....
0
votes
0
answers
30
views
What would be the hexadecimal representation of the largest memory address in a memory consisting of 4MB if each cell had a one-byte capacity?
What would be the hexadecimal representation of the largest memory address in a memory consisting of 4MB if each cell had a one-byte capacity?
Since 4MB is equal to 4*1,000,000 Bytes, can I assume ...
0
votes
0
answers
30
views
reduce the size of speed in packet payload
How can I reduce the size of speed data from 4-bytes to 2-bytes in C.
I have a packet payload of 41-bytes I reduced some data and now I have 39-bytes where I want my packet payload to be 36-byte.
The ...
1
vote
0
answers
19
views
Record Frame by Frame into a byteArrayOutputStreamVideoData and Save to a File
I am facing an issue with my APP.
Objective: It allows configuring the URL of an IP camera and displays what that camera captures on the screen. I need to create a functionality where, when the user ...
4
votes
1
answer
447
views
A byte type: std::byte vs std::uint8_t vs unsigned char vs char vs std::bitset<8>
C++ has a lot of types that vaguely describe the same thing. Assuming that we are compiling for an architecture where a byte is 8-bit, all of the following types are vaguely similar:
std::byte
std::...
1
vote
0
answers
52
views
Read non-byte-aligned value from byte array
I am trying to read a n-bit (n <= 8) long value from a byte[]. This value may not be aligned to the start/end of any byte or may span two bytes. To make this more clear, please see the following ...
0
votes
1
answer
30
views
Reading from a file using BufferedReader is giving garbage byte values in the String byte array like negative bytes
I am trying to read contents from an srt file and I am using Java's BufferedReader to read the file line by line. The content from the srt file is:
2
00:00:40,665 --> 00:00:44,806
<i>♪ Nants ...