Пример #1
0
        public static int Write(string value, int maxCharCount, bool unicode, byte[] buffer, int offset)
        {
            int num = Math.Min(value.Length, maxCharCount);

            if (!unicode)
            {
                for (int i = 0; i < num; i++)
                {
                    buffer[offset++] = ((value[i] < '\u0080') ? ((byte)value[i]) : 63);
                }
                buffer[offset++] = 0;
                return(num + 1);
            }
            int bytes = CTSGlobals.UnicodeEncoding.GetBytes(value, 0, num, buffer, offset);

            return(bytes + ExBitConverter.Write(0, buffer, offset + bytes));
        }
Пример #2
0
 public static int Write(string value, bool unicode, byte[] buffer, int offset)
 {
     return(ExBitConverter.Write(value, value.Length, unicode, buffer, offset));
 }
Пример #3
0
 public static int Write(char value, byte[] buffer, int offset)
 {
     return(ExBitConverter.Write((short)value, buffer, offset));
 }
Пример #4
0
 public unsafe static int Write(double value, byte[] buffer, int offset)
 {
     return(ExBitConverter.Write(*(long *)(&value), buffer, offset));
 }
Пример #5
0
 public unsafe static int Write(float value, byte[] buffer, int offset)
 {
     return(ExBitConverter.Write(*(int *)(&value), buffer, offset));
 }
Пример #6
0
 public static int Write(ulong value, byte[] buffer, int offset)
 {
     return(ExBitConverter.Write((long)value, buffer, offset));
 }
Пример #7
0
 public static int Write(long value, byte[] buffer, int offset)
 {
     ExBitConverter.Write((int)value, buffer, offset);
     ExBitConverter.Write((int)(value >> 32), buffer, offset + 4);
     return(8);
 }