binaryfiles

How do I generate a pdf-file from a binary file?

随声附和 提交于 2019-11-29 18:54:26
问题 How do I generate a pdf-file from a binary file retrieved from database in php5? It comes base64 encoded, and I just decoded it, but don't know what to do next... 回答1: The binary data is simply the actual file , or rather the important contents of that file, just without file name. $base64 = /* some base64 encoded data fetched from somewhere */; $binary = base64_decode($base64); And there you have the file data/contents of the file in the $binary variable. From here, it depends on what you

Git find all binary files in history

若如初见. 提交于 2019-11-29 18:34:09
问题 Sorry if this is a duplicate of previous question, but I couldn't find quite what I'm looking for. I'm in the process of converting a large cvs codeset (20+ repositories with 15 years of history - 10-15 GB size) to git. Much of the size is due to binaries that were committed along with the code in the past. While some of the binaries are files that can be removed completely, it's desirable to keep many of them as well as their history. However, we don't want the repo to bloat. We are

Mysql byte array storage

天大地大妈咪最大 提交于 2019-11-29 17:17:24
问题 I have a byte array created in Java. It represents content of some file. I don't know exactly the maximum size of this array. It can be different sizes. I want to store it in mysql. What type should I use in mysql? 回答1: Use BLOB, medium blob , varbinary Mysql Choosing the Right Type for a Column 回答2: Use varbinary to store byte arrays of arbitrary length in MySQL. 回答3: use a blob field java serialblob mysql blob 来源: https://stackoverflow.com/questions/11309040/mysql-byte-array-storage

What exactly causes binary file “gibberish”?

被刻印的时光 ゝ 提交于 2019-11-29 17:03:01
问题 I haven't found an answer to this particular question; perhaps there isn't one. But I've been wondering for a while about it. What exactly causes a binary file to display as "gibberish" when you look at it in a text editor? It's the same thing with encrypted files. Are the binary values of the file trying to be converted into ASCII? Is it possible to convert the view to display raw binary values, i.e. to show the 1s and 0s that make up the file? Finally, is there a way to determine what

How do computers translate everything to binary? When they see a binary code, how do they know if it represents a number or a word or an instruction?

微笑、不失礼 提交于 2019-11-29 14:55:14
问题 I know how computers translate numbers to binary. But what I don't understand is that I've heard that computers translate everything (words, instructions, ...) to binary, not just numbers. How is this possible? Could you show me some examples? Like how does a computer translate the letter "A" to binary? And when computers see a binary code, how can they know if that long string of 0s and 1s represents a number or a word or an instruction? . Exemple: Let's say that a computer programmer

Is it possible to confuse EOF with a normal byte value when using fgetc?

坚强是说给别人听的谎言 提交于 2019-11-29 14:38:34
We often use fgetc like this: int c; while ((c = fgetc(file)) != EOF) { // do stuff } Theoretically, if a byte in the file has the value of EOF , this code is buggy - it will break the loop early and fail to process the whole file. Is this situation possible? As far as I understand, fgetc internally casts a byte read from the file to unsigned char and then to int , and returns it. This will work if the range of int is greater than that of unsigned char . What happens if it's not (probably then sizeof(int)=1 )? Will fgetc read a legitimate data equal to EOF from a file sometimes? Will it alter

Why doesn't fwrite() write a Binary File using “wb”, in C, on Mac OS X?

与世无争的帅哥 提交于 2019-11-29 13:54:03
For the sake of learning C and understanding the difference between Binary Files and Text Files, I'm attempting to write a string to file as both file types like so: char * string = "I am a string!"; FILE * filePtrA = fopen("/output.txt", "wt"); fwrite(string, strlen(string), 1, filePtrA); FILE * filePtrB = fopen("/output.bin", "wb"); fwrite(string, strlen(string), 1, filePtrB); fclose(filePtrA); fclose(filePtrB); However both "wt" and "wb" are writing as a Text File, where "wb" should be writing as a Binary File. Hex appears like so for both files: 49 20 61 6D 20 61 20 73 74 72 69 6E 67 21

How do you edit a Binary Mainframe file in the RecordEditor using a Cobol Copybook (pt1)

落爺英雄遲暮 提交于 2019-11-29 12:22:12
How do you edit a Single-Record-type Binary Mainframe file in the RecordEditor using Cobol Copybook on a Windows or Linux PC. Note: This is an attempt to split a very broad question into a series of simpler Question and Answers. To Edit a File in the RecordEditor with a Cobol Copybook you must first load the copybook and then edit the file Loading the Cobol Copybook into the RecordEditor Select Record Layouts >>> Load Cobol Copybook menu options On the Cobol Load Screen enter the Cobol Copybook and your Mainframe Data file . The RecordEditor will read the file and try and work out what the

using bash: write bit representation of integer to file

好久不见. 提交于 2019-11-29 11:54:41
问题 I have a file with binary data and I need to replace a few bytes in a certain position. I've come up with the following to direct bash to the offset and show me that it found the place I want: dd bs=1 if=file iseek=24 conv=block cbs=2 | hexdump Now, to use "file" as the output: echo anInteger | dd bs=1 of=hextest.txt oseek=24 conv=block cbs=2 This seems to work just fine, I can review the changes made in a hex editor. Problem is, "anInteger" will be written as the ASCII representation of that

Packing and Unpacking binary float in python

南笙酒味 提交于 2019-11-29 07:14:08
I am having some trouble with packing and unpacking of binary floats in python when doing a binary file write. Here is what I have done: import struct f = open('file.bin', 'wb') value = 1.23456 data = struct.pack('f',value) f.write(data) f.close() f = open('file.bin', 'rb') print struct.unpack('f',f.read(4)) f.close() The result I get is the following: (1.2345600128173828,) What is going on with the extra digits? Is this a rounding error? How does this work? On most platforms, Python floats are what C would call a double , but you wrote your data out as float instead, which has half the