示例#1
0
 /// <summary>
 /// Writes a floating point number to a char array.
 /// </summary>
 /// <param name="value">The value to write</param>
 /// <param name="chars">The array to write to</param>
 /// <param name="offset">Position in the array to write to</param>
 /// <param name="precision">How many precision digits to include</param>
 /// <returns>Total number of characters that were written to the array</returns>
 public static unsafe int DoubleToUnicode(double value, char[] chars, int offset, int precision)
 {
     fixed(char *charptr = chars)
     {
         return(CharConverter.DoubleToUnicode(value, charptr, chars.Length, offset, precision));
     }
 }
示例#2
0
 /// <summary>
 /// Writes a numeric value to a char array in base 10.
 /// </summary>
 /// <param name="value">number to write</param>
 /// <param name="chars">array to write to.</param>
 /// <param name="offset">position in the array to write number to</param>
 /// <param name="numbase">the numeric base to write the number in</param>
 /// <returns>Total number of characters that were written to the array</returns>
 public static unsafe int UlongToUnicode(ulong value, char[] chars, int offset)
 {
     fixed(char *charptr = chars)
     {
         return(CharConverter.UlongToUnicode(value, charptr, chars.Length, offset));
     }
 }
示例#3
0
        public static unsafe void AppendPrimitive(this StringBuilder stringBuilder, ulong value)
        {
            char *buffer = stackalloc char[20];

            var count = CharConverter.UlongToUnicode(value, buffer, 20, 0);

            stringBuilder.Append(buffer, count);
        }
示例#4
0
        public static unsafe void AppendPrimitive(this StringBuilder stringBuilder, uint value)
        {
            char *buffer = stackalloc char[12];

            var count = CharConverter.UintToUnicode(value, buffer, 12, 0);

            stringBuilder.Append(buffer, count);
        }
示例#5
0
        /// <summary>
        /// Writes a numeric value to a char array in base 10.
        /// </summary>
        /// <param name="value">number to write</param>
        /// <param name="chars">array to write to.</param>
        /// <param name="offset">position in the array to write number to</param>
        /// <param name="numbase">the numeric base to write the number in</param>
        /// <returns>Total number of characters that were written to the array</returns>
        public static int IntToUnicode(int value, char[] chars, int offset)
        {
            if (value < 0)
            {
                int written = CharConverter.UintToUnicode((uint)-value, chars, offset + 1);

                // Add the minus afterwards to avoid modifying the char array incase of out of bounds.
                chars[offset] = '-';
                return(++written);
            }
            else
            {
                return(CharConverter.UintToUnicode((uint)value, chars, offset));
            }
        }
示例#6
0
        /// <summary>
        /// Writes a numeric value to a char array in base 10.
        /// </summary>
        /// <param name="value">number to write</param>
        /// <param name="chars">pointer to write to</param>
        /// <param name="length">size of the pointer</param>
        /// <param name="offset">where in the pointer to write to</param>
        /// <returns>Total number of characters that were written to the char pointer</returns>
        public static unsafe int LongToUnicode(long value, char *chars, int length, int offset)
        {
            if (value < 0)
            {
                int written = CharConverter.UlongToUnicode((ulong)-value, chars, length, offset + 1);

                // Add the minus afterwards to avoid modifying the char array incase of out of bounds.
                chars[offset] = '-';
                return(++written);
            }
            else
            {
                return(CharConverter.UlongToUnicode((ulong)value, chars, length, offset));
            }
        }
示例#7
0
 public void WriteULong(ulong ul)
 {
     this.Reserve(20);
     this.usagebound += CharConverter.UlongToUnicode(ul, this.buffer, this.usagebound);
 }
示例#8
0
 public void WriteUInt(uint ui)
 {
     this.Reserve(11);
     this.usagebound += CharConverter.UintToUnicode(ui, this.buffer, this.usagebound);
 }
示例#9
0
 public void WriteUShort(ushort us)
 {
     this.Reserve(6);
     this.usagebound += CharConverter.UintToUnicode(us, this.buffer, this.usagebound);
 }
示例#10
0
 public void WriteByte(byte b)
 {
     this.Reserve(4);
     this.usagebound += CharConverter.UintToUnicode(b, this.buffer, this.usagebound);
 }
示例#11
0
 public void WriteLong(long l)
 {
     this.Reserve(20);
     this.usagebound += CharConverter.LongToUnicode(l, this.buffer, this.usagebound);
 }
示例#12
0
 public void WriteInt(int i)
 {
     this.Reserve(11);
     this.usagebound += CharConverter.IntToUnicode(i, this.buffer, this.usagebound);
 }
示例#13
0
 public void WriteSByte(sbyte sb)
 {
     this.Reserve(4);
     this.usagebound += CharConverter.IntToUnicode(sb, this.buffer, this.usagebound);
 }
示例#14
0
 /// <summary>
 /// Writes a floating point number to a char array.
 /// </summary>
 /// <param name="value">The value to write</param>
 /// <param name="chars">The char pointer to write to</param>
 /// <param name="length">The total length of the char pointer</param>
 /// <param name="offset">Position in the char pointer to write to</param>
 /// <param name="precision">How many precision digits to include</param>
 /// <returns>Total number of characters that were written to the char pointer</returns>
 public static unsafe int FloatToUnicode(float value, char *chars, int length, int offset, int precision)
 => CharConverter.DoubleToUnicode(value, chars, length, offset, precision);
示例#15
0
 /// <summary>
 /// Writes a floating point number to a char array in base 10.
 /// </summary>
 /// <param name="value">The value to write</param>
 /// <param name="chars">The array to write to</param>
 /// <param name="offset">Position in the array to write to</param>
 /// <param name="precision">How many precision digits to include</param>
 /// <returns>Total number of characters that were written to the array</returns>
 public static int FloatToUnicode(float value, char[] chars, int offset, int precision)
 => CharConverter.DoubleToUnicode(value, chars, offset, precision);
示例#16
0
 public void WriteFloat(float f, int remainders)
 {
     this.Reserve(20);
     this.usagebound += CharConverter.FloatToUnicode(f, this.buffer, this.usagebound, remainders);
 }
示例#17
0
 public void WriteDouble(double f, int remainders)
 {
     this.Reserve(20);
     this.usagebound += CharConverter.DoubleToUnicode(f, this.buffer, this.usagebound, remainders);
 }
示例#18
0
 public void WriteShort(short s)
 {
     this.Reserve(6);
     this.usagebound += CharConverter.IntToUnicode(s, this.buffer, this.usagebound);
 }