binary-data

Python: Converting a Text File to a Binary File

拥有回忆 提交于 2020-03-16 08:09:20
问题 We can convert any digital file into binary file. I have a text file of 1MB, I want to convert it to a binary string and see the output as a binary number and the vice versa, in other words, if I have binary number, I want to convert it to a text file. How could I do that in Python? is there a standard way to do this? Now in this forum there are some posts (1,2,3, 4 ) on this but none of them answer properly to my question. 回答1: See https://docs.python.org/3/library/codecs.html#standard

Linux X86-64 assembly and printf

不打扰是莪最后的温柔 提交于 2020-02-01 05:04:25
问题 I am reading some linux assembly manuals and found idea about using printf() function. I need it to output register values for debugging reasons in binary form to terminal, but now I am tried simply to test that function with text. I am stuck, because of segfault when I am using pushq instead of pushl. How can I change this program to output strings and binary form of registers? .data input_prompt: .string "Hello, world!" printf_format: .string "%5d " printf_newline: .string "\n" size: .long

How to write raw type / bytes to stdout?

风格不统一 提交于 2020-01-24 03:49:08
问题 I am struggling for quite some time with outputting a raw type to standard output. Here is what I tried and did not work the desired way: r <- as.raw(c(0x41, 0x00, 0x43)) # r = "A\0C" cat(rawToChar(r)) # displays warning and skips data after NULL (outputs "A") cat(r) # outputs "41 00 43" writeBin(r, stdout()) # error: can only write to binary connection I am looking for a way to get all three bytes / characters printed to stdout. 回答1: If you are using an operating system that has a 'cat' or

What data type is suitable to handle binary data in ActiveX method?

妖精的绣舞 提交于 2020-01-22 15:17:25
问题 I'm writing an ActiveX control for my friend, that should encapsulate encryption routines. It will be used from VB6 primarily. What data type should I choose for binary data like encryption key, initialization vector, input and output data so that it would be convenient for my friend to use it from VB6? I'm using Delphi 7 to write this ActiveX, if that matters. One choice is to use hexadecimal strings. What can be the other? 回答1: VB6 Binary data stored in Byte variables and arrays. Dim

Insert image into xml file using c#

孤街浪徒 提交于 2020-01-21 01:34:36
问题 I've looked everywhere for the answer to this question but cant find anything so hoping you guys can help me on here. Basically I want to insert an image into an element in xml document that i have using c# I understand i have to turn it into bytes but im unsure of how to do this and then insert it into the correct element... please help as i am a newbie 回答1: Read all the bytes into memory using File.ReadAllBytes(). Convert the bytes to a Base64 string using Convert.ToBase64String(). Write

Insert image into xml file using c#

回眸只為那壹抹淺笑 提交于 2020-01-21 01:34:30
问题 I've looked everywhere for the answer to this question but cant find anything so hoping you guys can help me on here. Basically I want to insert an image into an element in xml document that i have using c# I understand i have to turn it into bytes but im unsure of how to do this and then insert it into the correct element... please help as i am a newbie 回答1: Read all the bytes into memory using File.ReadAllBytes(). Convert the bytes to a Base64 string using Convert.ToBase64String(). Write

Can I use C# Serialization to read a binary file in custom format?

a 夏天 提交于 2020-01-14 12:53:40
问题 I have a custom binary file which I want to read into my C# program. There are several different formats, some MSB first, some LSB first and some with the variables in different orders. Currently, I have a class which reads the right number of bytes, one at a time. It is very slow and so I am looking to improve performance any way I can. Is serialization likely to perform better? If so, is this possible with the scenario I have decsribed? Is it possible to customise the BinaryFormatter for

Why are binary files corrupted when zipping them?

不问归期 提交于 2020-01-13 18:54:34
问题 I have a service that delivers zipped files over the web. The zip contains executable files for the Windows platform. I'm using the RubyZip library to compress the file but the process corrupts the binary. At my local server we're using the zip command via a system call and it works fine. The zip command is not available at Heroku, and I'm simply out of options. I'm using this class: require 'zip/zip' # This is a simple example which uses rubyzip to # recursively generate a zip file from the

How to serve a file with JSP?

微笑、不失礼 提交于 2020-01-11 08:23:31
问题 This may sound totally stupid, but is a case of real life :( I'm able to display a HTML table with a "virtual" link name. Something like this: Xyz description <a href="docId=123">document.doc</a> Xyz description <a href="docId=456">documentB.doc</a> Xyz description <a href="docId=798">documentC.doc</a> This doc id represents an id in the database ( for these docs are stored in a blob as byte[] ) Anyway. I'm able to get that id, query the database and retrieve the byte[] ( and even store it in

How to serve a file with JSP?

邮差的信 提交于 2020-01-11 08:23:09
问题 This may sound totally stupid, but is a case of real life :( I'm able to display a HTML table with a "virtual" link name. Something like this: Xyz description <a href="docId=123">document.doc</a> Xyz description <a href="docId=456">documentB.doc</a> Xyz description <a href="docId=798">documentC.doc</a> This doc id represents an id in the database ( for these docs are stored in a blob as byte[] ) Anyway. I'm able to get that id, query the database and retrieve the byte[] ( and even store it in