Beispiel #1
0
        public string ReadUTF8String()
        {
            var num = ReadInt32();

            if (num == 0)
            {
                return(string.Empty);
            }
            if (num > 9999999 || num < 0)
            {
                LogCat.LogErrorFormat("ReadUTF8String error! length={0}", num);
                return(string.Empty);
            }

            var array = new byte[num];

            inputStream.Read(array, 0, num);
            return(ByteUtil.ToString(array));
        }
Beispiel #2
0
 /// <summary>
 /// 将o转化为string
 /// </summary>
 public static string ObjectToString(this object self)
 {
     if (self == null)
     {
         return(StringConst.String_null);
     }
     if (self.IsString())
     {
         return((string)self);
     }
     if (self.IsDateTime())
     {
         return(((DateTime)self).ToString(StringConst.String_yyyy_MM_dd));
     }
     if (IsChar(self))
     {
         return(((char)self).ToString());
     }
     if (IsChars(self))
     {
         return(new string((char[])self));
     }
     return(IsBytes(self) ? ByteUtil.ToString((byte[])self, 0, ((byte[])self).Length) : self.ToString());
 }