Created
June 24, 2023 07:45
-
-
Save pmachapman/6280e0cf6e9817b00832489224aefc63 to your computer and use it in GitHub Desktop.
Small Caps Generator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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