in src/Logging/TagsExtensions.cs [33:83]
public static string ToTagId(this EventId eventId)
{
int tagId = eventId.Id;
if (tagId <= 0xFFFF)
{
// Use straight numeric values
return tagId.ToString("x4", CultureInfo.InvariantCulture);
}
else if (tagId <= 0x3FFFFFFF)
{
// Use the lower 30 bits, grouped into 6 bits each, index into
// valuespace 'a'-'z','0'-'9' (reverse order)
char[] chars = new char[5];
for (int i = 4; i >= 0; i--)
{
int charVal = tagId & 0x3F;
tagId >>= 6;
if (charVal > 25)
{
if (charVal > 35)
{
chars[i] = '?';
}
else
{
chars[i] = (char)(charVal + 22);
}
}
else
{
chars[i] = (char)(charVal + 'a');
}
}
return new string(chars);
}
else
{
// Each byte represented as ASCII (reverse order)
byte[] bytes = BitConverter.GetBytes(tagId);
char[] characters = Encoding.ASCII.GetChars(bytes);
if (characters.Length > 0)
{
Array.Reverse(characters);
return new string(characters);
}
}
return "0000";
}