Beispiel #1
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));
     }
 }
Beispiel #2
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);
        }
Beispiel #3
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));
            }
        }
Beispiel #4
0
 public void WriteULong(ulong ul)
 {
     this.Reserve(20);
     this.usagebound += CharConverter.UlongToUnicode(ul, this.buffer, this.usagebound);
 }