C# .Net framework strings encoding from utf-8 bytes -


i have application wrote in c#, , application receives data through network server using sockets (udp libenet).

in application have function process raw bytes sent in packet. 1 of functions reading string, delimited \0.

my problem i'm sending utf-8 encoded string server c# application, when use these strings display them in controls, gibberish instead of polish letters.

function reads strings buffer:

public override string readstring() {      stringbuilder sb = new stringbuilder();      while (true)     {         byte b;         if (remaining > 0)             b = readbyte();         else             b = 0;          if (b == 0) break;          // here problem. checked other encodings etc., still same          sb.append(encoding.utf8.getstring(new byte[] { b }, 0, 1));     }      return sb.tostring(); } 

function overrides, 1 from:

public class bitreader : binaryreader 

in application get:

polish letters turned gibberish in dataviewgrid

you can't read utf-8 byte wise single character might take more 1 byte.

see how convert byte[] string? (first read 1 byte array / list).


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -