I am parsing a file (which I am not creating) that contains a string. The line is always preceded by 2 bytes, which tell me the length of the next line.
For instance:
05 00 53 70 6F 72 74
:
Sport
Using C # BinaryReader, I read the line using:
string s = new string(binaryReader.ReadChars(size));
Sometimes a weird funky character appears that seems to push the flow position further than it should. For instance:
0D 00 63 6F 6F 6B 20 E2 80 94 20 62 6F 6F 6B
Must be:
cook - book
and although it reads fine, the stream ends two bytes further than it should ?! (Which then messes up the rest of the parsing.)
I guess this has something to do with 0xE2 in the middle, but I'm not quite sure why and how to deal with it.
Any suggestions that were highly appreciated!
source
share