Linked Questions

Popular Questions

Strings encoded ASCII and UTF8 have different lengths!

Asked by At

I'm reading a stream and am wondering why the UTF-8 encoded string is shorter than the ASCII one.

  ASCIIEncoding encoder = new ASCIIEncoding();
  UTF8Encoding enc = new UTF8Encoding();   
  string response = encoder.GetString(message, 0, bytesRead); //4096
  string responseUtf8 = enc.GetString(message, 0, bytesRead);  //3955

Related Questions