Home All Groups Group Topic Archive Search About

Piped input contains Unicode preamble

Author
26 Apr 2007 9:42 PM
PIEBALD
I'm an old dog and I like old tricks, so I write a lot of utilities that
accept piped input.

e.g.
TYPE mydata.txt | MyApp
or
MyApp < mydata.txt
or
App1 | App2

Then read the input with System.Console.In

What I found though is that if the input file contains a Unicode preamble
(i.e. EF BB BF for UTF-8) the preamble appears in the data, which is
inconvenient.

I'm not real interested in _why_ this is the case, but I wonder what others
do to resolve this.

So far, because I'm only concerned with "ASCII" text, I simply ignore all
characters above 7F, but I'd like a more elegant solution.

One other thing I tried was rather than use
    System.Console.In
I tried
    new System.IO.StreamReader ( System.Console.OpenStandardInput , true )
which worked some times, but other times was missing the beginning of the
data (which I assume is due to buffering).

AddThis Social Bookmark Button