"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com...
Bill <nf*@nospam.com > wrote: This test now appears to be an issue with the StreamReader dropping
these unexpected characters.
Ah - and that's almost certainly just because you haven't given it the
right encoding. You haven't specified an encoding, so it's using UTF-8,
which I don't believe is what you really wanted.
See http://www.pobox.com/~skeet/csharp/unicode.html for more
information about encodings and Unicode.
You probably want to use Encoding.Defaul t in this case.
Yes... Encoding.Defaul t solved the problem.
The following modifications to my original test example works:
class Class1
{
static void Main(string[] args)
{
string str;
using (StreamWriter sro = new StreamWriter("P robDataOut.txt" ))
{
using (StreamReader sri = new StreamReader("P robDataIn.txt",
Encoding.Defaul t))
{
Console.WriteLi ne("---- TESTING FILE WITH PROBLEM CHARACTERS
HEX 'CC' and 'C8' ----");
while ( (str = sri.ReadLine()) != null )
{
Console.WriteLi ne("Length: " + str.Length);
Console.WriteLi ne("Output: " + str.Substring(1 84,1));
sro.WriteLine(s tr);
}
}
}
}
}