Skip to content

Instantly share code, notes, and snippets.

@midnightfreddie
Created May 4, 2016 02:43
Show Gist options
  • Save midnightfreddie/413c83a96a8298bc4e30b7a64645da3e to your computer and use it in GitHub Desktop.
Save midnightfreddie/413c83a96a8298bc4e30b7a64645da3e to your computer and use it in GitHub Desktop.
Random silliness: Adding a combining glyph to every a-z character in a string.
# Silliness. U0300 - U0036F are combining unicode characters
# https://en.wikipedia.org/wiki/Combining_Diacritical_Marks
$String = "The quick, brown fox jumped over the lazy dog"
$Combining = 0x0300 .. 0x036F | ForEach-Object { [char]$_ } | Sort-Object { Get-Random }
$i = 0
($String.ToCharArray() | ForEach-Object { $_ -replace '[A-Za-z]', "`$0$($Combining[$i++])" }) -join ""
# This looks a mess in ISE but will display "properly" in a browser or word processor when copied and pasted
# T͢h̖e͘ q̬u̚i̋c͝k͠, bͧr͉o͐w͟n̅ f͔oͤx̥ j̙uͅm̲p̸e̺d͞ oͣv͆eͨr͕ t̄h͜eͭ ļąz̉ẏ d̈́o͇g͖
# TODO: Currently the index will be out of range if (the number of alphabet characters in $String) -gt 112
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment