Advertisement
Guest User

Untitled

a guest
Feb 24th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. function Get-PhoneticString{
  2. param(
  3. [parameter(ValueFromPipeline=$true, Mandatory=$true)]
  4. [string]$StringToExplode,
  5. [string]$Delimiter = " - "
  6. )
  7. process{
  8. # Alphabetic conversions using military phonetics
  9. $phoneticAlphabet = @{
  10. "a" = "alfa"; "b" = "bravo"; "c" = "charlie"; "d" = "delta"; "e" = "echo";
  11. "f" = "foxtrot"; "g" = "golf"; "h" = "hotel"; "i" = "india"; "j" = "juliett";
  12. "k" = "kilo"; "l" = "lima"; "m" = "mike"; "n" = "november"; "o" = "oscar";
  13. "p" = "papa"; "q" = "quebec"; "r" = "romeo"; "s" = "sierra"; "t" = "tango";
  14. "u" = "uniform"; "v" = "victor"; "w" = "whiskey"; "x" = "x-ray"; "y" = "yankee";
  15. "z" = "zulu"
  16. }
  17.  
  18. $numberAsString = @{
  19. "0"="zero"; "1"="one"; "2"="two"; "3"="three"; "4"="four"
  20. "5"="five"; "6"="six"; "7"="seven"; "8"="eight"; "9"="nine"
  21. }
  22.  
  23. $symbolAsString = @{
  24. "!" = "Exclamation Mark"; '"' = "Double Quote"; "#" = "Number Sign"; "$" = "Dollar"; "%" = "Percent"; "&" = "Ampersand"
  25. "'" = "Single Quote"; "(" = "Left Parenthesis"; ")" = "Right Parenthesis"; "*" = "Asterisk"; "+" = "Plus"
  26. "," = "Comma"; "-" = "Minus"; "." = "Period"; "/" = "Slash"; ":" = "Colon"; ";" = "Semicolon"; "<" = "Less Than"
  27. "=" = "Equality Sign"; ">" = "Greater Than"; "?" = "Question Mark"; "@" = "At Sign"; "[" = "Left Square Bracket"
  28. "" = "Backslash"; "]" = "Right Square Bracket"; "^" = "Caret"; "_" = "Underscore"; '`' = "Grave / Accent"
  29. "{" = "Left Curly Bracket"; "|" = "Vertical Bar"; "}" = "Right Curly Bracket"
  30. }
  31.  
  32. # Convert this string into a character array. For each character find its string equivilent in one of the defined hash tables
  33. ($StringToExplode.ToCharArray() | ForEach-Object{
  34. switch -Regex -CaseSensitive ($_){
  35. "[a-z]"{$phoneticAlphabet."$_"}
  36. "[A-Z]"{($phoneticAlphabet."$_").ToUpper()}
  37. "d"{$numberAsString."$_"}
  38. "s"{$_}# Return whitespace unaltered
  39. default{ $symbolAsString."$_"}
  40. }
  41. }) -join $Delimiter
  42. }
  43.  
  44. }
  45.  
  46. "K0D3R3v13w" | Get-PhoneticString
  47. KILO - zero - DELTA - three - ROMEO - three - victor - one - three - whiskey
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement