Skip to content

Instantly share code, notes, and snippets.

@pmachapman
Created June 24, 2023 07:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pmachapman/6280e0cf6e9817b00832489224aefc63 to your computer and use it in GitHub Desktop.
Save pmachapman/6280e0cf6e9817b00832489224aefc63 to your computer and use it in GitHub Desktop.
Small Caps Generator
using System;
using System.Text;
Console.WriteLine("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
Console.WriteLine(SmallCaps("ABCDEFGHIJKLMNOPQRSTUVWXYZ"));
/// <summary>
/// Gets a the first match in capital letters as small caps.
/// </summary>
/// <param name="text">The text.</param>
/// <returns>The first match with all capital letters in small caps.</returns>
static string SmallCaps(string text)
{
StringBuilder sb = new StringBuilder();
foreach (char c in text)
{
sb.Append(c switch
{
'A' => '\u1D00',
'B' => '\u0299',
'C' => '\u1D04',
'D' => '\u1D05',
'E' => '\u1D07',
'F' => '\uA730',
'G' => '\u0262',
'H' => '\u029C',
'I' => '\u026A',
'J' => '\u1D0A',
'K' => '\u1D0B',
'L' => '\u029F',
'M' => '\u1D0D',
'N' => '\u0274',
'O' => '\u1D0F',
'P' => '\u1D18',
'Q' => '\uA7AF',
'R' => '\u0280',
'S' => '\uA731',
'T' => '\u1D1B',
'U' => '\u1D1C',
'V' => '\u1D20',
'W' => '\u1D21',
'X' => 'x',
'Y' => '\u028F',
'Z' => '\u1D22',
_ => c,
});
}
return sb.ToString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment