示例#1
0
        internal string ReadString()
        {
            int length = ReadU8();

            if (_compressed)
            {
                return(Sixbit.Decode(ReadBytes((int)Math.Ceiling(length * 6 / 8.0)), length));
            }

            return(_encoding.GetString(ReadBytes((length & 0b10111111) + 1)));
        }
示例#2
0
 internal void WriteString(string value)
 {
     if (_compressed)
     {
         WriteU8((byte)value.Length);
         WriteBytes(Sixbit.Encode(value));
     }
     else
     {
         WriteU8((byte)((value.Length - 1) | (1 << 6)));
         WriteBytes(_encoding.GetBytes(value));
     }
 }
示例#3
0
        internal string ReadString()
        {
            int length = ReadU8();

            if (_compressed)
            {
                return(Sixbit.Decode(ReadBytes((int)Math.Ceiling(length * 6 / 8.0)), length));
            }

#if NETSTANDARD2_1 || NET5_0_OR_GREATER
            return(_encoding.GetString(ReadBytes((length & 0xBF) + 1)));
#elif NETSTANDARD2_0
            return(_encoding.GetString(ReadBytes((length & 0xBF) + 1).ToArray()));
#endif
        }