I'm sure this is something very simple that I'm screwing up, but here goes:
I'm trying to parse a log file that is generally formatted in UNICODE (and I'll freely admit that I don't generally know much about UNICODE, but the first two bytes of the file are 0xFFFE, and there's a zero between every other character). The peculiar part is that this file appears to end lines with the byte sequence 0x0D000D0A, that is, \r\0\r\n, and that's apparently confusing my TextReader
from reading it.
That is, every other line I print is filled with:
?????????????????? ???????????? ? ????????? ? ????????????? ? ?????????????? ???? ??? ????? ???????????????????? ??? ???????????? ????????????????? ?????????????????????? ???????????????????? ?????? ????????????????????? ????????????? ?????
What is the recommended way for me to go about parsing this using C#? Or rather, what am I doing wrong?
Thanks!
Update: Sorry, I should have probably included the code I was using in my initial posting. Here it is:
FileStream fsa = File.Open(@"C:\InboxLOG.txt", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
TextReader sr = new StreamReader(fsa, Encoding.Unicode, true);
string line = "";
while ((line = sr.ReadLine()) != null)
{
Console.WriteLine(line);
}
Using StreamReader(fsa)
produces the same results.