Hello! The problem is in converting an array of bytes into a stream (Russian letters are replaced with question marks)
On the socket I get a message of totalByte size and write it into the byteMsg byte array. For further work, I need to convert this message to Stream.
If you convert an array of bytes into a string - everything is fine, Russian letters are displayed normally.
When I convert to stream, Russian letters are replaced with question marks. For check I transfer back to line and I bring to a log.
string text1 = Encoding.Default.GetString(byteMsg); text1 = text1.Substring(0, totalByte); Stream stream = new MemoryStream(byteMsg, 0, totalByte); stream.Position = 0; StreamReader reader = new StreamReader(stream); string text2 = reader.ReadToEnd(); log.Debug("text 1 = " + text1); log.Debug("text 2 = " + text2);
I see in the logs:
text 1 = русские буквы text 2 = ??????? ?????