Skip to main content
Filter by
Sorted by
Tagged with
461 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
  • 4,996
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
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
153 votes
2 answers
98k views

In a python source code I stumbled upon I've seen a small b before a string like in: b"abcdef" I know about the u prefix signifying a unicode string, and the r prefix for a raw string literal. What ...
kriss's user avatar
  • 24.3k
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
194 votes
8 answers
559k 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
193 votes
12 answers
643k 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
79 votes
8 answers
266k views

Is converting a file to a byte array the best way to save ANY file format to disk or database var binary column? So if someone wants to save a .gif or .doc/.docx or .pdf file, can I just convert it ...
Blankman's user avatar
  • 269k
125 votes
4 answers
152k views

I have the following Java code: byte value = 0xfe; // corresponds to -2 (signed) and 254 (unsigned) int result = value & 0xff; The result is 254 when printed, but I have no idea how this code ...
dagronlund's user avatar
  • 1,670
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
101 votes
6 answers
88k views

What is the maximum number of bytes for a single UTF-8 encoded character? I'll be encrypting the bytes of a String encoded in UTF-8 and therefore need to be able to work out the maximum number of ...
Edd's user avatar
  • 8,630
20 votes
6 answers
23k views

byte a = 1; byte b = 1; byte c = a + b; Throws error: possible loss of precision byte subt = a_s - a_b; ^ required: byte found: int Is this behavior has something to do with ...
Prateek's user avatar
  • 12.3k
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
72 votes
7 answers
30k views

I've always assumed: that a char is represented by a byte, that a byte can always be counted upon to have 8 bits, that sizeof (char) is always 1, and that the maximum theoretical amount of memory I ...
lindelof's user avatar
  • 35.4k
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
58 votes
1 answer
144k views

I am trying to verify a bytearray with Image.open and Image.verify() without writing it to disk first and then open it with im = Image.open(). I looked at the .readfrombuffer() and .readfromstring() ...
ato's user avatar
  • 913
26 votes
3 answers
5k views

The ISO C Standard requires CHAR_BIT to be at least 8. With POSIX mandating CHAR_BIT be equal to 8, and (almost?) all networking and communication standards using octets, is there any contemporary C ...
Jens's user avatar
  • 73.3k
92 votes
4 answers
220k views

Possible Duplicate: C Macro definition to determine big endian or little endian machine? int main() { int x = 1; char *y = (char*)&x; printf("%c\n",*y+48); } If it's little endian it ...
ordinary's user avatar
  • 6,143
74 votes
6 answers
196k views

I need to convert objects to a byte[] to be stored in the Tokyo Cabinet key-value store. I also need to unbyte the byte[] to an Object when reading from the key-value store. Are there any packages ...
volni's user avatar
  • 5,406
77 votes
2 answers
99k views

I see that a number of people have had a similar problem, however I'm yet to try find exactly what I'm looking for. So, I have a method which reads an input image and converts it to a byte array: ...
user1875290's user avatar
55 votes
14 answers
233k views

I am working with Python3.2. I need to take a hex stream as an input and parse it at bit-level. So I used bytes.fromhex(input_str) to convert the string to actual bytes. Now how do I convert these ...
user904832's user avatar
94 votes
4 answers
197k views

I'm going to be storing a large array of byte values (most likely over a million) in Javascript. If I use a normal array with normal numbers, that will take 8 MB, because numbers are stored as IEEE ...
Kendall Frey's user avatar
  • 44.6k
56 votes
7 answers
59k views

I'm having some issues taking audio data stored in a byte array, converting it to a big-endian short array, encoding it, then changing it back into a byte array. Here is what I have. The original ...
Aaron's user avatar
  • 561
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
114 votes
12 answers
282k views

I need to convert a number into an unsigned byte. The number is always less than or equal to 255, and so it will fit in one byte. I also need to convert that byte back into that number. How would I ...
darksky's user avatar
  • 21.2k

1
2 3 4 5
19