Exemple #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));
        }
Exemple #2
0
 public static int Write(string value, bool unicode, byte[] buffer, int offset)
 {
     return(ExBitConverter.Write(value, value.Length, unicode, buffer, offset));
 }
Exemple #3
0
 public static int Write(char value, byte[] buffer, int offset)
 {
     return(ExBitConverter.Write((short)value, buffer, offset));
 }
Exemple #4
0
 public unsafe static int Write(double value, byte[] buffer, int offset)
 {
     return(ExBitConverter.Write(*(long *)(&value), buffer, offset));
 }
Exemple #5
0
 public unsafe static int Write(float value, byte[] buffer, int offset)
 {
     return(ExBitConverter.Write(*(int *)(&value), buffer, offset));
 }
Exemple #6
0
 public static int Write(ulong value, byte[] buffer, int offset)
 {
     return(ExBitConverter.Write((long)value, buffer, offset));
 }
Exemple #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);
 }