public Utf8String ToUtf8String(UUIDRepresentation representation, bool compact) { Span <char> tmp = stackalloc char[MaxStringLength]; if (!TryFormat(tmp, out int charsWritten, representation, compact)) { throw new Exception(); } return(new Utf8String(tmp.Slice(0, charsWritten))); }
public bool TryFormat( Span <char> destination, out int charsWritten, UUIDRepresentation representation = UUIDRepresentation.HyphenHex, bool compact = false) { // The hyphen are set to split the UUID into numbers of the format 8-4-4-4-12 with // each number marking the number of hexadecimal digits fitting into the corresponding section. // 00000001-0002-0003-0004-000000000005 == 1-2-3-4-5 // 00000001000200030004000000000005 == 1000200030004000000000005 if (representation == UUIDRepresentation.IntArray) {