byte

What is the byte signature of a password-protected ZIP file?

I've read that ZIP files start with the following bytes: 50 4B 03 04 Reference: http://www.garykessler.net/library/file_sigs.html Question: Is there a certain sequence of bytes that indicate a ZIP file has been password-protected? ...

c++ how to add a zero bits byte or null to a string

Hi I am doing a simple client implementation of TFTP. Here i need to send read request in following format /* send request 2 bytes string 1 byte string 1 byte ------------------------------------------------------ RRQ/ | 01/02 | Filename | 0 | Mode | 0 | WRQ -----------------------------------------...

Searching for a sequence of Bytes in a Binary File with Java

I have a sequence of bytes that I have to search for in a set of Binary files using Java. Example: I'm searching for the byte sequence DEADBEEF (in hex) in a Binary file. How would I go about doing this in Java? Is there a built-in method, like String.contains() for Binary files? ...

PHP - determine how many bytes sent over http

Is it possible in PHP to get a count of the number of bytes transmitted to the client? For example, if I'm outputting a 10 MB file, is there a way to find out if all 10 MB were sent to the client, or to see if the client interrupted the transfer partway? I know Apache will log this afterwards, but I'd like to access the data in PHP. ...

Using JavaScript to truncate text to a certain size (8 KB)

I'm using the Zemanta API, which accepts up to 8 KB of text per call. I'm extracting the text to send to Zemanta from Web pages using JavaScript, so I'm looking for a function that will truncate my text at exactly 8 KB. Zemanta should do this truncation on its own (i.e., if you send it a larger string), but I need to shuttle this text a...

Read bytes from string as floats

I've got a python webserver where small binary files are POST:ed. The posted data is represented as strings. I want to examine the contents of these strings. But to do that, I need to convert each 4 bytes to floats (little endian). How do you do that? ...

Confusing type conversion - 2 Bytes to Double

I was recently asked to take over a project in which waveform data is sampled from a power converter and sent to an intelligent agent where calculations are done and the appropriate actions are taken based on the results. The following (java)snippet is what the previous coder used to convert the byte array into an array of doubles: ...

Sending part of byte array over the network using WCF

I have a byte array of some binary data that i need to send over the network using WCF and NetTcpBinding. My problem is that i need to send only the part of the array. Is there any way to do this, other than copying that part to a separate array, and sending that one. This extra copying degrades performance, and i would like to avoid it,...

In Java, what's the fastest way to "build" and use a string, character by character?

I have a Java socket connection that is receiving data intermittently. The number of bytes of data received with each burst varies. The data may or may not be terminated by a well-known character (such as CR or LF). The length of each burst of data is variable. I'm attempting to build a string out of each burst of data. What is the fast...

How do you insert a string of escaped HTML that is larger than 4096 bytes into a CKEditor instance?

I recently brushed up against Firefox's 4096 byte (4KB) limit for individual XML nodes when using Paul Schreiber's unescapeHtml string method to insert a large string of escaped HTML into a CKEditor instance. This approach did not handle a string over 4KB in size in Firefox 3.5.3 due to the browser splitting the content into multiple no...

MFC: How to i convert DWORD and BYTE to LPCTSTR in order to display in MessageBox

I'm using VS2005 with "using Unicode Character Set" option typedef unsigned char BYTE; typedef unsigned long DWORD; BYTE m_bGeraet[0xFF]; DWORD m_dwAdresse[0xFF]; How do i make the code work? MessageBox (m_bGeraet[0], _T("Display Content")); MessageBox (m_dwAdresse[0], _T("Display Content")); ...

Transfer Byte array from server to browser

I have a database column that contains the contents of a file. I'm converting this into a byte[] on the server (I don't want to save the file to the disk) and then want to send this to the client to download. The file can be any thing (pdfs, pics, word, excel, etc). I have the file name so I know the extension but I'm not sure how the ...

Byte Array to Image File

I am given a byte[] array in Java which contains the bytes for an image, and I need to output it into an image. How would I go about doing this? Much thanks ...

Convert Byte String to Int in Scheme

I have code like this to convert hex into byte string (define (word->bin s) (let ((n (string->number s))) (bytes (bitwise-and (arithmetic-shift n -24) #xFF) (bitwise-and (arithmetic-shift n -16) #xFF) (bitwise-and (arithmetic-shift n -8) #xFF) (bitwise-and n #xFF)))) (word->bin "#x10000002") I'm thinking of a similar...

how to convert CString to Bytes

i am actually tryin to convert a csharp code to c... below is the C# code.. CString data = "world is beautiful"; Byte[] quote = ASCIIEncoding.UTF8.GetBytes(data); in the above code... it converts the string into bytes..similarily is ther a way that i can convert it using C.. Can any body tell what wud be the quivalent code in C? P...

PInvoke on the Windows Mobile platform

So I'm trying to invoke a function I have in my unmanaged C++ dll. void foo(char* in_file, char * out_file) In my C# application I declare the same function as [DllImport("dll.dll")] public static extern void foo(byte[] in_file, byte[] out_file); The actual parameters I pass through an ASCII encoder like so byte[] param1 = Encodi...

How to Convert Byte* to std::string in C++?

I have Byte *, want to convert it to std::string. Can you please tell me the safest way to do this? ...

Visual Studio C++ 2008 Manipulating Bytes?

I'm trying to write strictly binary data to files (no encoding). The problem is, when I hex dump the files, I'm noticing rather weird behavior. Using either one of the below methods to construct a file results in the same behavior. I even used the System::Text::Encoding::Default to test as well for the streams. StreamWriter^ binWriter =...

Bytes to Binary in C

Hello, I'm trying to simply convert a byte received from fget into binary. I know the value of the first byte was 49 based on printing the value. I now need to convert this into its binary value. unsigned char byte = 49;// Read from file unsigned char mask = 1; // Bit mask unsigned char bits[8]; // Extract the bits for (int i = 0; ...

Image data of PCX file

I have a big binary file with lots of files stored inside it. I'm trying to copy the data of a PCX image from the file and write it to a new file which I can then open in an image editor. After obtaining the specs for the header of a PCX file I think that I've located the image in the big binary file. My problem is that I cannot figure ...