Write in Morse Code

More Details

One famous piece of Morse code is "... --- ...", a distress signal for "SOS" that stands for "Save Our Souls".

What Your Function Should Do

Write a function ToMorseCode that takes a string of English text and outputs the Morse code translation. Use "/" to separate words.

ToMorseCode["This is not a pipe"]

ToMorseCode["Wolfram Challenges"]

To avoid ambiguity, separate each character with a single whitespace character:

ToMorseCode["use spaces"]

Here are all positions of whitespace characters in the previous example:

StringPosition[%," "][[All,1]]

Treat uppercase and lowercase characters the same:

ToMorseCode["SAME"]

ToMorseCode["same"]

More Examples

A long piece of text:

ToMorseCode["When in the Course of human events, it becomes necessary for one people to dissolve the political bands which have connected them with another, and to assume, among the Powers of the earth, the separate and equal station to which the Laws of Nature and of Nature's God entitle them, a decent respect to the opinions of mankind requires that they should declare the causes which impel them to the separation."]

Things You May Find Useful

The following list, morseAlphabet, is a list of the letters of the Morse code alphabet, in alphabetical order (a–z):

morseAlphabet={".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--.."};

ToMorseCode[text_String]:=