Skip to main content
Filter by
Sorted by
Tagged with
-3 votes
0 answers
57 views

I'm kind of a beginner in all this CS stuff but let me try to explain what I'm asking. A bit is basically an "on" or "off" switch which just stores the value of either "true&...
Manuel's user avatar
  • 1
Advice
0 votes
4 replies
53 views

from PIL import Image img = Image.open('some/file.png') img = img.convert(mode='1') imgbytes = img.tobytes() with open('filepath', 'w') as file_out: file_out.write(imgbytes) I would like to write the ...
Cutter's user avatar
  • 1,862
0 votes
1 answer
59 views

I am receiving my ".wav" file in a django view as an "InMemoryUploadedFile" then converting it to bytes: views.py import functions.bytes_to_wav_wave if voice_value: ...
Mohammed Baashar's user avatar
1 vote
1 answer
138 views

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, ...
Lucy's user avatar
  • 95
0 votes
2 answers
63 views

Below is the code extracted from this repo: import os.path, io filename = "" n_chunks = 12 # Number of processes to use -- will split the file up into this many pieces def ...
Akira's user avatar
  • 2,820
0 votes
1 answer
176 views

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 ...
bquark's user avatar
  • 21
4 votes
2 answers
177 views

I am trying to make my own file compressor and some of the chars in the file that I am trying to compress are '�'. I tried: #include <iostream> int main(){ std :: cout << (int)'�'; ...
Jordon's user avatar
  • 103
994 votes
21 answers
2.0m views

I'm converting something from VB into C#. Having a problem with the syntax of this statement: if ((searchResult.Properties["user"].Count > 0)) { profile.User = System.Text.Encoding....
nouptime's user avatar
  • 10.6k
504 votes
35 answers
608k views

I got this code to covert size in bytes via PHP. Now I want to convert those sizes to human readable sizes using JavaScript. I tried to convert this code to JavaScript, which looks like this: ...
l2aelba's user avatar
  • 22.3k
1 vote
2 answers
139 views

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 ...
infinitychances's user avatar
679 votes
37 answers
944k views

When I executed the following command: ALTER TABLE `mytable` ADD UNIQUE ( `column1` , `column2` ); I got this error message: #1071 - Specified key was too long; max key length is 767 bytes ...
Steven's user avatar
  • 25.5k
0 votes
2 answers
130 views

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 ...
Manuel Selva's user avatar
  • 19.1k
924 votes
11 answers
2.4m views

I've very recently migrated to Python 3.5. This code was working properly in Python 2.7: with open(fname, 'rb') as f: lines = [x.strip() for x in f.readlines()] for line in lines: tmp = line....
masroore's user avatar
  • 10.2k
-2 votes
2 answers
133 views

I want to add a byte after every third byte in a byte array. # This is an example of where the bytes would be added b'\xF2\xA1\x23{ADD}\xFF\x00\x05{ADD}\xE2\x20\x05{ADD}...' Usually, I have a byte ...
Nitroxy's user avatar
  • 50
1 vote
2 answers
147 views

I would like to switch between different BYTE Arrays after user input. I need to apply the same processing to different arrays depending on user input, but I would like to avoid repeating the code. ...
Alex's user avatar
  • 13
0 votes
1 answer
62 views

I've a rabbitMQ implementation (C# with RabbitMQ.Client 7.1.12 nuget) where we send a short json to a queue. But when the receiver gets the queue item sometimes (approximately 1 on 5) the byte array ...
BvdVen's user avatar
  • 2,961
462 votes
25 answers
653k views

I am looking for a way to convert a long string (from a dump), that represents hex values into a byte array. I couldn't have phrased it better than the person that posted the same question here. But ...
rafraf's user avatar
  • 5,006
176 votes
31 answers
214k views

Just wondering if .NET provides a clean way to do this: int64 x = 1000000; string y = null; if (x / 1024 == 0) { y = x + " bytes"; } else if (x / (1024 * 1024) == 0) { y = string.Format("{0:...
John Smith's user avatar
  • 4,536
407 votes
10 answers
331k views

I am working with a library which returns a "byte string" (bytes) and I need to convert this to a string. Is there actually a difference between those two things? How are they related, and ...
Sheldon's user avatar
  • 10.2k
0 votes
1 answer
121 views

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 "...
winter's user avatar
  • 67
-5 votes
1 answer
80 views

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"...
Bulova's user avatar
  • 1
227 votes
19 answers
303k views

How do I convert a long to a byte[] and back in Java? I'm trying convert a long to a byte[] so that I will be able to send the byte[] over a TCP connection. On the other side I want to take that byte[...
Emre801's user avatar
  • 3,253
0 votes
0 answers
64 views

I have gone through dozens of articles, and this StackOverflow thread but I'm still as clueless as ever. The main points I have read everywhere and why I don't understand them are: The main points I ...
Mayank Rajput's user avatar
0 votes
1 answer
43 views

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 ...
21k's user avatar
  • 439
235 votes
15 answers
478k views

I got an integer: 1695609641 when I use method: String hex = Integer.toHexString(1695609641); system.out.println(hex); gives: 6510f329 but I want a byte array: byte[] bytearray = new byte[] { (...
stefan's user avatar
  • 2,353
-3 votes
1 answer
73 views

Input: unsigned char vet[] = { 0xBC,0xFF,0x01 };unsigned short int len = 18; Output: short int minLung;short int maxLung; Given a sequence of bits, determine the minimum and maximum length of ...
Tania Volo's user avatar
194 votes
8 answers
560k views

I'm currently working on an encryption/decryption program and I need to be able to convert bytes to an integer. I know that: bytes([3]) = b'\x03' Yet I cannot find out how to do the inverse. What am ...
Vladimir Shevyakov's user avatar
220 votes
13 answers
120k views

In C++, Why is a boolean 1 byte and not 1 bit of size? Why aren't there types like a 4-bit or 2-bit integers? I'm missing out the above things when writing an emulator for a CPU
Asm's user avatar
  • 2,211
4 votes
1 answer
129 views

I am trying to create and save KeePass entries using pykeepass and saving a .txt file as an attachment. However I get a type-error: Traceback (most recent call last): File "c:\Users\...
Simplicissimus's user avatar
231 votes
13 answers
780k views

Does an Integer variable in C occupy 2 bytes or 4 bytes? What are the factors that it depends on? Most of the textbooks say integer variables occupy 2 bytes. But when I run a program printing the ...
Rajiv Prathap's user avatar
193 votes
12 answers
644k views

I'm trying to understand a byte[] to string, string representation of byte[] to byte[] conversion... I convert my byte[] to a string to send, I then expect my web service (written in python) to echo ...
0909EM's user avatar
  • 5,077
143 votes
14 answers
499k views

I want to convert a byte array to an image. This is my database code from where I get the byte array: public void Get_Finger_print() { try { using (SqlConnection thisConnection = new ...
Tanzeel ur Rahman's user avatar
162 votes
13 answers
351k views

I am writing a prototype TCP connection and I am having some trouble homogenizing the data to be sent. At the moment, I am sending nothing but strings, but in the future we want to be able to send ...
Steve H.'s user avatar
  • 3,393
209 votes
11 answers
1.0m views

I have to store some constant values (UUIDs) in byte array form in java, and I'm wondering what the best way to initialize those static arrays would be. This is how I'm currently doing it, but I feel ...
dfickling's user avatar
  • 2,705
122 votes
14 answers
280k views

For example, the bits in a byte B are 10000010, how can I assign the bits to the string str literally, that is, str = "10000010". Edit I read the byte from a binary file, and stored in the ...
Sean's user avatar
  • 4,555
102 votes
4 answers
173k views

I have a bytes type object like this: b"{'one': 1, 'two': 2}" I need to get proper python dictionary from the above bytes type object using python code. string = b"{'one': 1, 'two': 2}&...
Harathi's user avatar
  • 1,129
0 votes
0 answers
45 views

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 ...
Arn's user avatar
  • 1
1 vote
3 answers
82 views

I am using a TCP-client program to catch a list of bytes, and when I send such a list of bytes, this is what I see: I want to capture those characters in a logfile, so I did the following: log.Debug($...
Dominique's user avatar
  • 17.6k
131 votes
14 answers
232k views

I've done some research. A byte is 8 bits and a word is the smallest unit that can be addressed on memory. The exact length of a word varies. What I don't understand is what's the point of having a ...
user avatar
3 votes
2 answers
172 views

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 ...
q9f's user avatar
  • 11.9k
147 votes
14 answers
188k views

I have a javascript string which is about 500K when being sent from the server in UTF-8. How can I tell its size in JavaScript? I know that JavaScript uses UCS-2, so does that mean 2 bytes per ...
Paul Biggar's user avatar
163 votes
4 answers
227k views

I'm wondering if I can know how long in bytes for a string in C#, anyone know?
user705414's user avatar
  • 21.3k
163 votes
10 answers
243k views

I would like to know how much space does my MySQL database use, in order to select a web host. I found the command SHOW TABLE STATUS LIKE 'table_name' so when I do the query, I get something like this:...
marvin's user avatar
  • 1,945
0 votes
0 answers
48 views

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 ...
user3840530's user avatar
109 votes
6 answers
204k views

I want to hash given byte[] array with using SHA1 Algorithm with the use of SHA1Managed. The byte[] hash will come from unit test. Expected hash is 0d71ee4472658cd5874c5578410a9d8611fc9aef (case ...
Merve Kaya's user avatar
  • 1,249
131 votes
10 answers
248k views

I need to create a client-server example over TCP. In the client side I read 2 numbers and I send them to the server. The problem I faced is that I can't convert from []byte to int, because the ...
Emanuel's user avatar
  • 6,992
0 votes
2 answers
469 views

Trying to create a function that converts objects to byte arrays (without the overhead/metadata things like BinaryFormatter create). I think I'm happy with the following code except the ability of it ...
Arvo Bowen's user avatar
  • 4,968
0 votes
1 answer
103 views

I see a lot of questions and answer regarding converting a byte array into string however my case is quite different and I cannot for the life of me find a way to do what I need. I generate a result ...
Rami Aboulissane's user avatar
1 vote
1 answer
561 views

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 ...
rwutscher's user avatar
95 votes
11 answers
211k views

I have an instance of a struct that I defined and I would like to convert it to an array of bytes. I tried []byte(my_struct), but that did not work. Also, I was pointed to the binary package, but I am ...
abw333's user avatar
  • 6,001

1
2 3 4 5
157