Last active
March 18, 2023 05:06
-
-
Save Mike-Crowley/b2a63bfe6bd533452bca3125037594a1 to your computer and use it in GitHub Desktop.
Replace a given letter with the superscript letter (except q).
This file contains 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
function Get-Superscript { | |
param ($letter) | |
switch ($letter) { | |
"a" { [char]::ConvertFromUtf32(7491 )} | |
"b" { [char]::ConvertFromUtf32(7495 )} | |
"c" { [char]::ConvertFromUtf32(7580 )} | |
"d" { [char]::ConvertFromUtf32(7496 )} | |
"e" { [char]::ConvertFromUtf32(7497 )} | |
"f" { [char]::ConvertFromUtf32(7584 )} | |
"g" { [char]::ConvertFromUtf32(7501 )} | |
"h" { [char]::ConvertFromUtf32(688 )} | |
"i" { [char]::ConvertFromUtf32(8305 )} | |
"j" { [char]::ConvertFromUtf32(690 )} | |
"k" { [char]::ConvertFromUtf32(7503 )} | |
"l" { [char]::ConvertFromUtf32(737 )} | |
"m" { [char]::ConvertFromUtf32(7504 )} | |
"n" { [char]::ConvertFromUtf32(8319 )} | |
"o" { [char]::ConvertFromUtf32(7506 )} | |
"p" { [char]::ConvertFromUtf32(7510 )} | |
"q" { "q" } # https://www.quora.com/Why-is-there-no-character-for-superscript-q-in-Unicode | |
"r" { [char]::ConvertFromUtf32(691 )} | |
"s" { [char]::ConvertFromUtf32(738 )} | |
"t" { [char]::ConvertFromUtf32(7511 )} | |
"u" { [char]::ConvertFromUtf32(7512 )} | |
"v" { [char]::ConvertFromUtf32(7515 )} | |
"w" { [char]::ConvertFromUtf32(695 )} | |
"x" { [char]::ConvertFromUtf32(739 )} | |
"y" { [char]::ConvertFromUtf32(696 )} | |
"z" { [char]::ConvertFromUtf32(7611 )} | |
default { $letter } # to support string conversion | |
} | |
} | |
# example 1: | |
Get-Superscript -letter m | |
# returns: ᵐ | |
# example 2: | |
$String = "Mike Crowley!" | |
($String -split "" | foreach {Get-Superscript $_} ) -join '' | |
# returns: ᵐⁱᵏᵉ ᶜʳᵒʷˡᵉʸ! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment