I am comparing to files by reading it into filestream and comparing byte by byte..now how can i skip whitespaces while comparing?I am using C#.net
+3
A:
byte b;
// ....
if (Char.IsWhiteSpace((char) b))
{
// skip...
}
EDIT: As Eric Lippert points out, this is only correct if the encoding of the file is plain 7-bit ASCII. In any other encoding it will skip relevant bytes. So, you should take into account the encoding of your data.
Mitch Wheat
2009-09-25 11:10:40
This is only correct if the encoding of the file is plain 7 bit ASCII. In any other encoding it will skip relevant bytes.
Eric Lippert
2009-09-25 14:20:53
@Eric Lippert: Hi, the poster said he was comparing bytes, but you are correct; he should be taking into account the encoding.
Mitch Wheat
2009-09-25 14:33:22