Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

byte[] <----> Char

Status
Not open for further replies.

andreiaron

Programmer
Jul 18, 2002
6
RO
Hi, i am trying to use a network stream in c#. I need to both read and write
strings, some integral types (short, byte).

I tried using a StreamReader and a StreamWriter on this stream. But the
StrteamReader only gives char reading options (unicode utf8 2 bytes chars) .
If i try to read at the same time from the stream itself, i can't find
anything there (probably because the inner buffer of the streamReader
empties the buffer of the strteam regularly)

so i decided that the only option is to operate at a byte level.
So, i need to convert shorts, chars, to bytes and viceversa.

Thanks, i hope someone can help me.

Andrei

 
Take a look at the UTF8Encoding class. It has a method (GetChars) to convert a byte array into a character array. You can then concatenate them together into a String.

There's also an ASCIIEncoding class.

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top