title: Sending a string containing special characters through a TcpClient (byte[])
body: <p>I'm trying to send a string containing special characters through a TcpClient (byte[]). Here's an example:</p>
  
  <ul>
  <li>Client enters "amé" in a textbox</li>
  <li>Client converts string to byte[] using a certain encoding <em>(I've tried all the predefined ones plus some like "iso-8859-1")</em></li>
  <li>Client sends byte[] through TCP</li>
  <li>Server receives and outputs the string reconverted with the same encoding (to a listbox)</li>
  </ul>
  
  <p>Edit :</p>
  
  <p>I forgot to mention that the resulting string was "am?".</p>
  
  <p>Edit-2 (as requested, here's some code):</p>
  
  <p>@DJKRAZE here's a bit of code :</p>
  
  <pre><code>byte[] buffer = Encoding.ASCII.GetBytes("amé");
  (TcpClient)server.Client.Send(buffer);
  </code></pre>
  
  <p>On the server side:</p>
  
  <pre><code>byte[] buffer = new byte[1024];
  Client.Recieve(buffer);
  string message = Encoding.ASCII.GetString(buffer);
  ListBox1.Items.Add(message);
  </code></pre>
  
  <p>The string that appears in the listbox is "am?"</p>
  
  <p>=== Solution ===</p>
  
  <pre><code>Encoding encoding = Encoding.GetEncoding("iso-8859-1");
  byte[] message = encoding.GetBytes("babé");
  </code></pre>
  
  <p>Update:</p>
  
  <p>Simply using <code>Encoding.Utf8.GetBytes("ééé");</code> works like a charm.</p>