byte

What is the size of the memory area pointed to by an unsigned char *?

Ok, I know this has been asked before but after searching I couldn't find a proper answer. I need to convert a buffer (unsigned char *) to base64, the base64 function I am using takes as paramters: void Base64Enc(const unsigned char *src, int srclen, unsigned char *dest) where int srclen is the length of the src string. My question ...

Convert BYTE buffer (0-255) to float buffer (0.0-1.0)

How can I convert a BYTE buffer (from 0 to 255) to a float buffer (from 0.0 to 1.0)? Of course there should be a relation between the two values, eg: 0 in byte buffer will be .0.f in float buffer, 128 in byte buffer will be .5f in float buffer, 255 in byte buffer will be 1.f in float buffer. Actually this is the code that I have: for (...

How is this 13 bytes long?

Two quotes: All of the remaining messages in the protocol take the form of <length prefix><message ID><payload>. The length prefix is a four byte big-endian value. The message ID is a single decimal byte. The payload is message dependent. request: <len=0013><id=6><index><begin><length> The request message is fixed length, and...

SHA-1 Hashes Mixed with Strings

I have to parse something like the following "some text <40 byte hash>" can i read this whole thing in to a string without corrupting 40 byte hash part? The thing is hash is not going to be there so i don't want to process it while reading. EDIT: I forgot to mention that the 40 byte hash is 2x20 byte hashes no encoding raw bytes. ...

java creating byte array whose size is represented by a long

Hi all, I'm trying to create a byte array whose size is of type long. For example, think of it as: long x = _________; byte[] b = new byte[x]; Apparently you can only specify an int for the size of a byte array. Before anyone asks why I would need a byte array so large, I'll say I need to encapsulate data of message formats that I ...

where can i find a byte to float lookup table?

I initially was looking for a way convert byte to float, and found answers that indicate the fastest was is to create a lookup table. So i was wondering if anyone know of a pre-existing lookup table that i can use. ...

C# How to write one byte at an offset?

Im trying to write a single byte at a certain location in a file. This is what im using at the moment: BinaryWriter bw = new BinaryWriter(File.Open(filename, FileMode.Open)); bw.BaseStream.Seek(0x6354C, SeekOrigin.Begin); bw.Write(0xB0); bw.Close(); The problem is that BinaryWriter.Write(args) writes a four-byte signed integer at the ...

What is quicker, writing text to a file or converting to bytes and writing it to a file?

I have a requirement to write HTML to the file system and I was wondering if there is any speed boost in converting it to bytes and writing it using a FileStream rather than using the File.WriteAllText() (or a similar text method). ...

RSS Video Feed Enhancement - Need to get duration on items that dont include it in feed

I have a working DNLA device (Xbox360, PSP...) RSS Video feed reader in C#. It parses .opml files to get the feed uri. Sometimes an RSS feed item will not have a duration value, so I am hard coding a default duration value when it doesn't. I want to get the true duration of the video file. My idea is to use httpWebRequest to get a b...

Does NSNumber add any extra bytes to the number it holds?

I'm working with Objective-C and I need to add int's from a NSArray to a NSMutableData (I'm preparing a to send the data over a connection). If I wrap the int's with NSNumber and then add them to NSMutableData, how would I find out how many bytes are in the NSNumber int? Would it be possible to use sizeof() since according to the apple d...

F#: Converting a string into an array of bytes

I'm writing a simple rc4 encryption/decryption utility as a first project. I'm stuck on trying to convert the given string into an array of bytes that can then be manipulated by the core algorithm. How do you convert a string into an array of bytes in functional f#? //From another thread let private replace find (repl : string) (str : s...

parsing bytes (C Windows)

I have a DWORD value that in Hex might look like: DWORD Val = 0xFF01091A How can I read each byte? What I mean is, how can I read FF, 01, 09 and 1A? Thanks! ...

How to implement C# enum for enumerated char(1) database field?

OK, so I have a database field of type char(1) that has a small number of possible state codes (e.g. 'F'= Failure, 'U'=Unknown, etc.). I'd like to have a C# enum class that corresponds to these states. I can do: public enum StatusCode : byte { Unknown = (byte) 'U', Failure = (byte) 'F', // etc. } So far so good. But in ...

Extra bytes in .mid files

Hi everyone. I'm trying to read information from a .mid file, but I keep seeing extra bytes that don't seem to be part of any midi messages. I'm not sure how to predict/deal with these and it's throwing everything else off in my project. Any suggestions? Here's a few examples: 4d 54 72 6b 00 00 04 48 Track Header 00 c0 19 ...

How Does Ruby handle bytes/binary?

I'm trying to send a series of binary bytes across a socket, to meet a particular standard my company uses. No one in my company has used Ruby for this before, but in other languages, they send the data across one byte at a time, (usually with some sort of "pack" method). I can't find anyway to create binary on the fly, or create bytes...

OR-ing bytes in C# gives int

I have this code. byte dup = 0; Encoding.ASCII.GetString(new byte[] { (0x80 | dup) }); When I try to compile I get: Cannot implicitly convert type 'int' to 'byte'. An explicit conversion exists (are you missing a cast?) Why does this happen? Shouldn't | two bytes give a byte? Both of the following work, assuring that each i...

Trouble converting a byte array on the iphone...

I'm having a little dilemma with an iphone project. I'm getting some JSON data from a webservice. I can deserialize it into a dictionary OK. One of the dictionary values is a binary (a picture), but my JSON library deserializes it as an NSArray of NSDecimalNumbers! How do I convert this NSArray of NSDecimalNumbers to an NSData object, ...

char array assignment and management

I'm supposed to write a library in c++ that should handle the connections to the kad network. I'm trying to build a packet accordant to those used by aMule&co. And I really can't understand the difference between this code: buffer = "\xe4\x20\x02"; and, for example, this code: char p_buffer[36]; p_buffer[0] = 0xe4; p_buffer[1] = 0x2...

How to read a single BIT in an Array of Bytes?

The problem is that I have an Array of Byte with 200 Indexes and just want to check that is the Fourth bit of MyArray[75] is Zero(0) or One(1). byte[] MyArray; //with 200 elements //check the fourth BIT of MyArray[75] ...

C++ byte stream

Hi Everyone, For a networked application, the way we have been transmitting dynamic data is through memcpying a struct into a (void*). This poses some problems, like when this is done to an std::string. Strings can be dynamic length, so how will the other side know when the string ends? An idea I had was to use something similiar to Java...