Currently, there isn't a NetworkStream.Peek method in C#. What is the best way of implementing such a method which functions just like NetworkStream.ReadByte except that the returned byte is not actually removed from the Stream?
...
I have a socket where server is in JAVA but Client is in C++.
Struct{
float length;
char[] name;
}myStruct;
How can I convert the structures to a byte stream sent by Server and can be correctly parsed by Client? Any sample code would help! (I heard XML is an option but I am not familiar with it ) Thanks.
...
I have a javascript string which is about 500K when being sent from the server in UTF-8. How can I tell its size in JavaScript?
I know that JavaScript uses UCS-2, so does that mean 2 bytes per character. However, does it depend on the JavaScript implementation? Or on the page encoding or maybe content-type?
...
Hi
Why result of
include <stdio.h>
int main()
{
unsigned short int i = 0xff ;
unsigned short int j;
j= i<<2;
printf("%x n%x\n", i, j);
return 0;
}
is j = 3fc ?
if both i and j are short int - so they are 2bytes values, so j shouldnt =fc ??
thx in advance for explanations.
~
~
...
Is it possible to get specific bytes from a byte array in java?
I have a byte array:
byte[] abc = new byte[512];
and i want to have 3 different byte arrays from this array.
byte 0-127
byte 128-255
byte256-511.
I tried abc.read(byte[], offset,length) but it works only if I give offset as 0, for any other value it throws an ...
If ObjectAlloc cannot deduce type information for the block, it uses 'GeneralBlock'. Any strategies to get leaks from this block that may eliminate the need of my 'trial and error' methods that I use? The Extended Detail thing doesn't really do it for me as I just keep guessing.
...
i have a person object and need to store it as byte[] and again retrieve that byte[] and convert to person object
and BinaryFormatter is not availabe in silverlight
...
This has to do with a question I read yesterday:
http://stackoverflow.com/questions/2274428/how-to-determine-how-many-bytes-an-integer-needs
Anyway, the part that I have a question about is this:
I'm looking for the most efficient way to calculate the minimum number of bytes needed to store an integer without losing precision.
...
I have a method to create a hashed password.
However it crashes at salt.CopyTo(pwd, 0);
Says that the target byte[] is too small.
How do I solve the problem?
public static byte[] CreateHashedPassword(string password, byte[] salt)
{
SHA1 sha1 = SHA1.Create();
byte[] pwd = CustomHelpers.StringToByteArray(pa...
I'm trying to verify someone's password when logging in.
I take the entered password and retrieve the users saved hashed password and password salt.
Then I hash the entered password with the saved salt to see if it's equal to the saved password.
However, even though the byte[] storedPassword is exactly like the byte[] enteredPassword,...
I need to parse the bytes from a file so that I only take the data after a certain sequence of bytes has been identified. For example, if the sequence is simply 0xFF (one byte), then I can use LINQ on the collection:
byte[] allBytes = new byte[] {0x00, 0xFF, 0x01};
var importantBytes = allBytes.SkipWhile(byte b => b != 0xFF);
// importa...
Is it possible to create a method like BitConverter.GetBytes() that accepts as input also a parameter of type Object, without using Marshaling as done here?
Or the only solution, if a type Object is given as input, is to implement a case on all available .NET value types?
...
I have the following function from the php.net site to determine the # of bytes in an ASCII and UTF-8 string:
<?php
/**
* Count the number of bytes of a given string.
* Input string is expected to be ASCII or UTF-8 encoded.
* Warning: the function doesn't return the number of chars
* in the string, but the number of bytes.
* ...
In bytes_test.go I see:
a := Split([]byte(tt.s), []byte(tt.sep), tt.n)
where tt.s and tt.sep are strings. But when I try to do
a := bytes.Split([]byte("test"), []byte("e"), 0)
I get:
cannot convert "test" (type ideal string) to type []uint8 in conversion
cannot convert "e" (type ideal string) to type []uint8 in conversion
...
I have an array with 16 elements. I would like to evaluate these to a boolean 0 or 1 and then store this in 2 bytes so i can write to a binary file. How do I do this?
...
I noticed that in C# there are both a byte and Byte data type. They both say they are of type struct System.Byte and represent an 8-digit unsigned integer.
So I am curious as to what the difference if any is between the two, and why you would use one over the other.
Thanks!
...
hello
I have need to pack four signed bytes into 32-bit integral type.
this is what I came up to:
int32_t byte(int8_t c) { return (unsigned char)c; }
int pack(char c0, char c1, ...) {
return byte(c0) | byte(c1) << 8 | ...;
}
is this a good solution? Is it portable (not in communication sense)?
is there a ready-made solution, perha...
Using the link below, I wrote a code for my application. I am not able to get it right though, Please refer the link and help me ot with it...
http://stackoverflow.com/questions/263518/c-uploading-files-to-file-server
The following is my code:-
protected void Button1_Click(object sender, EventArgs e)
{
filePath = FileUpload1.Fi...
I need to add header info to a JPEG file in order to get it to work properly when shared on some websites, I've tracked down the correct info through a lot of Hex digging, but now I'm kind of stuck trying to get it into the file. I know where in the file it needs to go, and I know how long it is, my problem is that RandomAccessFile just...
I know Java doesn't allow unsigned types, so I was wondering how it casts an integer to a byte. Say I have an integer a with a value of 255 and I cast the integer to a byte. Is the value represented in the byte 11111111? In other words, is the value treated more as a signed 8 bit integer, or does it just directly copy the last 8 bits of ...