Function Repository Resource:

MorseCipher

Source Notebook

Encode a string with extended Morse code

Contributed by: Aster Ctor

ResourceFunction["MorseCipher"][string]

encodes string with extended Morse code.

Details and Options

The original Morse code can only work on "a"–"z", 0–9 and " ".
ResourceFunction["MorseCipher"] extends the definition to encode almost all Unicode characters.
The TargetFunctions option (the default value of which is Audio) is used to support different output types:
Audioreturn the Morse code in audio form
Listreturn the Morse code written using “.” and “-” in the form of a list
Stringreturn the Morse code written using ".", "-" and "/"

Examples

Basic Examples (1) 

Generate an SOS Morse code in audio form:

In[1]:=
ResourceFunction["MorseCipher"]["SOS"]
Out[1]=

Scope (1) 

Generate an SOS Morse code in written form:

In[2]:=
ResourceFunction["MorseCipher"]["SOS", TargetFunctions -> String]
Out[2]=

Options (2) 

AllowUpperCase (2) 

Specify the permission of uppercase letters:

In[3]:=
SOS = ResourceFunction["MorseCipher"]["SOS", "AllowUpperCase" -> True]
Out[3]=

Decipher with the resource function MorseDecipher:

In[4]:=
ResourceFunction["MorseDecipher"]@SOS
Out[4]=

Properties and Relations (3) 

Show built-in rules:

In[5]:=
ResourceFunction["MorseCipher"][Rule]
Out[5]=

The encoder will look for built-in characters first:

In[6]:=
ResourceFunction["MorseCipher"]["a", TargetFunctions -> String]
Out[6]=

If not found, it will be calculated based on Unicode code:

In[7]:=
ResourceFunction["MorseCipher"]["\[Alpha]", TargetFunctions -> String]
Out[7]=

Neat Examples (1) 

Use the extended Morse code to encode ancient Chinese poetry:

In[8]:=
ResourceFunction["MorseCipher"]["苟利国家生死以, 岂因祸福避趋之?"]
Out[8]=

Publisher

Aster Ctor (MoeNet)

Version History

  • 1.0.0 – 18 November 2019

Related Resources

License Information