The blog continues at suszter.com/WindowsMobile

Saturday, February 21, 2015

Displaying Binary Characters

The wrong way to display an array of random characters in the console (standard output) is like this.

    foreach (Byte by in buffer) {
        System.Console.Write(Convert.ToChar(by));
    }

It only displays ASCII characters (0-127) correctly. If you want your code to display ANY characters correctly you may use something like this.

    Console.OpenStandardOutput().Write(buffer, 0, buffer.Length);

Here is the complete example code.


You can download the source code here.

No comments:

Post a Comment