public static byte ReadByte(Stream s)
 {
     int v = s.ReadByte();
     if (v == -1)
         throw new Exception("IOException: EOF");
     return (byte)v;
 }
 public static int InternalReadByte(Stream s)
 {
     int v = s.ReadByte();
     if (v == -1)
         throw new Exception("IOException: EOF");
     return v;
 }
 public static uint ReadUInt32(Stream s)
 {
     int a = s.ReadByte();
     int b = s.ReadByte();
     int c = s.ReadByte();
     int d = InternalReadByte(s);
     return (uint)((a << 24) | (b << 16) | (c << 8) | d);
 }
 public static ushort ReadUInt16(Stream s)
 {
     int a = s.ReadByte();
     int b = InternalReadByte(s);
     return (ushort)((a << 8) | b);
 }
 public static char ReadChar(Stream s)
 {
     int a = s.ReadByte();
     int b = InternalReadByte(s);
     return (char)((a << 8) | b);
 }
 public static sbyte ReadSByte(Stream s)
 {
     int v = s.ReadByte();
     return (sbyte)v;
 }
 private static int InternalReadInt16(Stream s)
 {
     int a = s.ReadByte();
     int b = InternalReadByte(s);
     return ((a << 8) | b);
 }
 private static int ReadUtfChar(Stream s, StringBuilder sb)
 {
     int a = InternalReadByte(s);
     if ((a & 0x80) == 0)
     {
         sb.Append((char)a);
         return 1;
     }
     if ((a & 0xe0) == 0xb0)
     {
         int b = InternalReadByte(s);
         sb.Append((char)(((a & 0x1F) << 6) | (b & 0x3F)));
         return 2;
     }
     if ((a & 0xf0) == 0xe0)
     {
         int b = s.ReadByte();
         int c = InternalReadByte(s);
         sb.Append((char)(((a & 0x0F) << 12) | ((b & 0x3F) << 6) | (c & 0x3F)));
         return 3;
     }
     throw new Exception("IOException: UTFDataFormat:");
 }