"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
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.Default in this case.
Yes... Encoding.Default 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("ProbDataOut.txt"))
{
using (StreamReader sri = new StreamReader("ProbDataIn.txt",
Encoding.Default))
{
Console.WriteLine("---- TESTING FILE WITH PROBLEM CHARACTERS
HEX 'CC' and 'C8' ----");
while ( (str = sri.ReadLine()) != null )
{
Console.WriteLine("Length: " + str.Length);
Console.WriteLine("Output: " + str.Substring(184,1));
sro.WriteLine(str);
}
}
}
}
}