bytearray

C# Read Line from Byte Array (Not Convert Byte Array to String)

I have a byte array that I am reading in from a NetworkStream. The first two bytes tell the length of the packet that follows and then the packet is read into a byte array of that length. The data in that I need to read from the NetworkStream/byte array has a few Strings, i.e. variable length data terminated by new line characters, and s...

Simulating ByteArrays using ActionScript 2?

Any replacement for the AS3 ByteArray where you can read raw binary data via any medium? Maybe load a TXT file and access the characters byte-by-byte? Any ideas? ...

Strange characters returned from byte stream?

When trying to display a byte stream from HLDS (Half-Life Dedicated Server) in a textbox, it displays strange blocky question mark characters that look something like this: [?] Here's a sample line from the byte stream (with [?] in place of the strange character): CPU In Out Uptime Users FPS Players[?] 0.00 0.97 0.91 ...

Deserialize a byte array to a struct

I get a transmission over the network that's an array of chars/bytes. It contains a header and some data. I'd like to map the header onto a struct. Here's an example: #pragma pack(1) struct Header { unsigned short bodyLength; int msgID; unsigned short someOtherValue; unsigned short protocolVersion; }; int main() { ...

WPF Image to Byte[]

Im trying to convert from System.Windows.Controls.Image to byte[] and I didnt know which method from Image class could help in this scenary, by the way I really dont know what should I do, cause in my LINQ model the field appears as Bynary type, I have to change this if I want to save it like a byte[] type? thanks! I found code posted h...

Need loop to copy chunks from byte array

I have to process a large byte array that is passed to my function. I need to copy the content from this incoming byte array in smaller "chunks" to an outbound byte array. For every "chunk" of data created in the outbound array, I need to call a web service. Upon return, I need to resume looping through the incoming byte array, continu...

Sending ByteArray to Zend_Amf

I'm having problems sending a ByteArray over to my Zend_Amf_server. I get a NetConnection.Bad.Call back from the server. If I send a variable with another datatype then ByteArray it works fine. I used the same script before with AMFPHP witouth any problems. But for this project I really need this to work in Zend_Amf. AS3: var path:S...

How to convert Byte array into string ?

I have structure as follows: struct data {int no; string name; int id}; I am converting this structure into bytearray. I need to convert this back into structure format. For that I need to convert first members into integer and string. How to convert bytearray into structure ? ...

Convert byte array to Python string

Hi, I'm using this code to get standard output from an external program: >>> from subprocess import * >>> command_stdout = Popen(['ls', '-l'], stdout=PIPE).communicate()[0] The communicate() method returns an array of bytes: >>> command_stdout b'total 0\n-rw-rw-r-- 1 thomas thomas 0 Mar 3 07:03 file1\n-rw-rw-r-- 1 thomas thomas 0...

An equivalent of javax.nio.Buffer.flip() in c#

I am porting some of the java code and need to be able to flip (javax.nio.Buffer.flip()). I am using byte[] to store data, and I want to flip these byte array, much like Buffer does it, as I believe underneath Buffer class uses byte[] as well. Thanks ...

using jpeglib for JPEG compressed byte stream

Hello all, I have JPEG compressed byte stream stored in a variable called "Image" and I want to convert this byte stream to RGB. Eg: unsigned char *Image; My question is: Is there any way to pass "Image" to jpeg_stdio_src() to get the RGB color values? Can anyone tell me how I could use jpeglib library to get RGB from byte stream "I...

Structs to Byte Arrays to send over sockets

What is the best way to get a byte array from a struct to send over TCP sockets? I'm using .Net (VB or C#). ...

wcf + Byte array through wcf service using MTOM

Hi, How to pass Byte array through wcf service using MTOM..please give me any sample ...

convert bool[] to byte[] C#

I have a list. I want to convert it to a byte[]. How do i do this? .toarray() creates a bool[]. ...

How do I transform an ascii byte vector into a string?

Given a byte array (byte[]) is there any quick (as in short and aesthetic) way of transforming this into a string och character array? Assume that the bytes in the array is text represented in ascii. I'm working in c# right now, and can't find any obvious methods to use. But I'm also interested in a general solution applicable to any m...

How to convert NSData to byte array in iPhone?

I want to convert NSData to a byte array, so I write the following code: NSData *data = [NSData dataWithContentsOfFile:filePath]; int len = [data length]; Byte byteData[len]; byteData = [data bytes]; But the last line of code pops up an error saying "incompatible types in assignment". What is the correct way to convert the data to by...

Using a UUID as a Database Primary Key, Java type is a byte[]

Are there any issues with using a byte[] as a primary key in a JPA Entity? I want to use a UUID as my primary key, but stored as a string I feel it will be too large. I was thinking of doing something like this to store the ID as a byte[] and set it as my Entity's ID: public static byte[] byteArray(UUID uuid) { long lsb = uu...

Storing UUID as base64 String

I have been experimenting with using UUIDs as database keys. I want to take up the least amount of bytes as possible, while still keeping the UUID representation human readable. I think that I have gotten it down to 22 bytes using base64 and removing some trailing "==" that seem to be unnecessary to store for my purposes. Are there an...

IronPython - Convert int to byte array

What is the write way to get the length of a string in Python, and then convert that int to a byte array? What is the right way to print that to the console for testing? ...

Converting Byte array to Int-likes in C#

BitConverter.ToUInt16() expects the bytes to be reversed, i guess that's how they are stored in memory. But how can I convert it when it's not reversed, w/o modifying the array? Byte[] ba = { 0, 0, 0, 6, 0, 0 }; BitConverter.ToUInt16(ba, 2); // is 1536/0x0600, but I want 6/0x0006 ...