Console encoding

  • Thread starter Thread starter David Michaels
  • Start date Start date
D

David Michaels

Is it possible to change the encoding of Console.Out (I think not), or, how
can output just raw bytes to stdout? There is no Console.Write() overload
which takes a byte (the one that takes an object just does a ToString() on a
given byte object). I understand why Console would force it's own encoding
on stdout when simply outputting text to a console (dos box) window, but if
I'm redirecting/piping to another console, I want raw bytes. Any ideas?
Thanks.
 
The short answer is that DrawString() API only accept string, so even if you
enforce it to accept byte, it'll have to convert it to string
later anyway.

If you really want to push "bytes" to Console.Out, you'll probably want to
try Console.OpenStandardOutput() method which will
open a normal Steam object.
 
Is it possible to change the encoding of Console.Out (I think not), or, how
can output just raw bytes to stdout? There is no Console.Write() overload
which takes a byte (the one that takes an object just does a ToString() on a
given byte object). I understand why Console would force it's own encoding
on stdout when simply outputting text to a console (dos box) window, but if
I'm redirecting/piping to another console, I want raw bytes. Any ideas?
Try Console.OutputEncoding/Console.InputEncoding.
Present in .NET 2.0 only.
 
Back
Top