public static TextBuff NewTextBuff(Stream strm)
{
// First check if this is a UTF16 file
//
int b0 = strm.ReadByte();
int b1 = strm.ReadByte();
if (b0 == 0xfe && b1 == 0xff)
return new BigEndTextBuff(strm);
if (b0 == 0xff && b1 == 0xfe)
return new LittleEndTextBuff(strm);
int b2 = strm.ReadByte();
if (b0 == 0xef && b1 == 0xbb && b2 == 0xbf)
return new TextBuff(strm);
//
// There is no unicode preamble, so we
// must go back to the UTF8 default.
//
strm.Seek(0, SeekOrigin.Begin);
return new TextBuff(strm);
}