I\'m trying to send a string containing special characters through a TcpClient (byte[]). Here\'s an example:
Your problem appears to be the Encoding.ASCII.GetBytes("amé");
and Encoding.ASCII.GetString(buffer);
calls, as hinted at by '500 - Internal Server Error' in his comments.
The é
character is a multi-byte character which is encoded in UTF-8 with the byte sequence C3 A9
. When you use the Encoding.ASCII
class to encode and decode, the é
character is converted to a question mark since it does not have a direct ASCII encoding. This is true of any character that has no direct coding in ASCII.
Change your code to use Encoding.UTF8.GetBytes()
and Encoding.UTF8.GetString()
and it should work for you.