|  | 
|  | 
| back to board | Discussion of Problem 1345. HTMLWA#9 C# Help (or other high level languages) I spent 5+ hours trying to understand why I am having WA#9.DON'T use high level classes/methods like Console.Write/StreamReader/StreamWriter. Process input and send to output as raw bytes. I didn't find what was the issue (I am already tired with this shit), but I suppose StreamWriter or StreamReader can mess up with \r \n characters in some cases.
 
 Here is code example for WA#9. I use Console.OpenStandardInput(0) as input, and Console.OpenStandardOutput(0) as output.
 
 
 private static void SolveStateMachine(Stream input, Stream output)
 {
 using var writer = new StreamWriter(output, Encoding.ASCII, 1024);
 
 void Write(char ch)
 {
 writer.Write(ch);
 }
 
 void WriteS(string str)
 {
 writer.Write(str);
 }
 
 ...
 }
 
 When I change about code to below, I am getting AC:
 
 private static void SolveStateMachine(Stream input, Stream output)
 {
 void Write(char ch)
 {
 byte[] buffer = new byte[1];
 buffer[0] = (byte)ch;
 output.Write(buffer, 0, 1);
 }
 
 void WriteS(string str)
 {
 byte[] buffer = Encoding.ASCII.GetBytes(str);
 output.Write(buffer, 0, buffer.Length);
 }
 
 ...
 }
Re: WA#9 C# Help (or other high level languages) I got it. Test#9 is about characters with code >= 128. I was using Encoding.ASCII in C#, which causes replacing of all such characters with '?'. If your high level classes use UTF-8 encoding by default, you will also have problems. | 
 | 
|