/// <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> /// <returns>Total number of characters that were written to the array</returns> public static unsafe int UintToUnicode(uint value, char[] chars, int offset) { fixed(char *charptr = chars) { return(CharConverter.UintToUnicode(value, charptr, chars.Length, offset)); } }
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); }
/// <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 IntToUnicode(int value, char *chars, int length, int offset) { if (value < 0) { int written = CharConverter.UintToUnicode((uint)-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.UintToUnicode((uint)value, chars, length, offset)); } }
public void WriteUInt(uint ui) { this.Reserve(11); this.usagebound += CharConverter.UintToUnicode(ui, this.buffer, this.usagebound); }
public void WriteUShort(ushort us) { this.Reserve(6); this.usagebound += CharConverter.UintToUnicode(us, this.buffer, this.usagebound); }
public void WriteByte(byte b) { this.Reserve(4); this.usagebound += CharConverter.UintToUnicode(b, this.buffer, this.usagebound); }