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 ...
994
votes
21
answers
2.0m
views
Converting string to byte array in C#
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....
504
votes
35
answers
608k
views
Correct way to convert size in bytes to KB, MB, GB in JavaScript
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:
...
679
votes
37
answers
943k
views
MySQL Error #1071 - Specified key was too long; max key length is 767 bytes
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
...
924
votes
11
answers
2.4m
views
"TypeError: a bytes-like object is required, not 'str'" when handling file content in Python 3
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....
1
vote
2
answers
147
views
How to switch between different BYTE Arrays after user input?
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. ...
176
votes
31
answers
214k
views
Does .NET provide an easy way convert bytes to KB, MB, GB, etc.?
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:...
-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
0
answers
64
views
What is the diffrence between a byte string and a normal string in python? [duplicate]
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 ...
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 ...
-3
votes
1
answer
73
views
I can't find the error in this code. It is x86 assembly
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 ...
4
votes
1
answer
125
views
Adding text file attachments to Keepass with pykeepass in python
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\...
231
votes
13
answers
780k
views
Is the size of C "int" 2 bytes or 4 bytes?
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 ...
143
votes
14
answers
499k
views
Byte array to image conversion
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 ...
209
votes
11
answers
1.0m
views
How do I initialize a byte array in Java?
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 ...
122
votes
14
answers
280k
views
How to convert a byte to its binary string representation
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 ...
102
votes
4
answers
173k
views
How to convert bytes type to dictionary [duplicate]
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}&...
131
votes
14
answers
232k
views
What's the difference between a word and byte?
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 ...
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 ...
163
votes
10
answers
243k
views
How to Get True Size of MySQL Database?
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:...
0
votes
2
answers
461
views
How can I convert a UInt32[] and a Int32[] array to byte arrays?
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 ...
131
votes
10
answers
247k
views
How to convert from []byte to int in Go Programming
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 ...
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....
95
votes
11
answers
211k
views
In Go, how can I convert a struct to a byte array?
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 ...