L.MorseCodeTranslator 1.0.2.4

There is a newer version of this package available.
See the version list below for details.
dotnet add package L.MorseCodeTranslator --version 1.0.2.4                
NuGet\Install-Package L.MorseCodeTranslator -Version 1.0.2.4                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="L.MorseCodeTranslator" Version="1.0.2.4" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add L.MorseCodeTranslator --version 1.0.2.4                
#r "nuget: L.MorseCodeTranslator, 1.0.2.4"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install L.MorseCodeTranslator as a Cake Addin
#addin nuget:?package=L.MorseCodeTranslator&version=1.0.2.4

// Install L.MorseCodeTranslator as a Cake Tool
#tool nuget:?package=L.MorseCodeTranslator&version=1.0.2.4                

C#

alt text

MorseCode-Translator

A small morsecode translator written in C# for general morsecode translation for a console app.

Description

This is one of the very first versions of my MorseCode-Translator containing simple convertions. It makes use of a flexible MorseCharCollection in which you can chose from plenty of characters to display. You can either start with the whole alphabet, only a few of them or completely new ones that are not defined yet (e.g dollar sign $).

The library offers:

  • Basic alphabet convertions from text-to-morse/morse-to-text
  • Basic alphabet soundfile creation aswell as output to console
  • Custom morsecharacter convertions from text-to-morse/morse-to-text
  • Custom morsecharacter soundfile creation aswell as output to console

Whats still in my toDo:

  • Morse-soundfile-to-text-conversion (Soundfile → MorseChar)

Installation

To install the library, you can use the NuGet-package market through visual studio or per NuGet package installer:

dotnet add package L.MorseCodeTranslator --version xxx

Or the build in version in Visual Studio:

NuGet\Install-Package L.MorseCodeTranslator -Version xxx

Newest version is listed here: https://www.nuget.org/packages/L.MorseCodeTranslator/

Usage

Depending on what you want to use you can go different routes.

Getting started

To make complete use of the MorseCode-Translator start by creating an instance of a MorseCodeTranslator:

MorseCodeTranslator translator = new MorseCodeTranslator();

The constructor with no parameters initializes all MorseChars from the alphabet inside of a MorseCharCollection. Alternatively you can create only a handful of MorseChars with custom MorseRepresentations:

List<MorseChar> morseList = new List<MorseChar>
{
    new MorseChar('n', "..."),
    new MorseChar('a',".--"),
    new MorseChar('h',".-.-")
};

MorseCharCollection morseCharCollection = new MorseCharCollection(morseList);
MorseCodeTranslator translator = new MorseCodeTranslator(morseCharCollection);
//use translator and or the collection from here on...

Once you've created a collection or a translator, you can now start using their methods for MorseConvertions or SoundFile convertions. Keep in mind that if you chose to use only a handful of MorseChars, the MorseCodeTranslator wont have access to the specific soundfiles of the alphabet.

However, if there are only e.g. 3 chars inside the MorseCodeTranslator and you use any kind of convertion method, the MorseCodeTranslator refers back to the original MorseRepresentations from the alphabet (See examples).

MorseConvertions

First of all, you can convert the whole MorseCharCollection back into its MorseRepresentations and use it for example like so:

string[] morseRepresentations = morseCharCollection.ConvertToMorseCharRepresentation();
for (int i = 0; i < morseRepresentations.Length; i++)
{
    Console.WriteLine(morseRepresentations[i]);
}	
//Output with example MorseCharCollection from before
//...
//.--
//.-.-

Moreover, you can use the translator to for example read a string input and convert it to the MorseCharRepresentations:

while (true)
{
    Console.WriteLine("Type in some text: ");
    string input = Console.ReadLine();
    try
    {
        string[] inputToMorse = translator.ConvertStringToMorse(input);
        for (int i = 0; i < inputToMorse.Length; i++)
        {
            Console.WriteLine(inputToMorse[i]);
        }
    }
    catch (MorseCharNotFoundException ex)
    {
        Console.WriteLine("Wrong input: " + ex.Message);
    }
}
//input: hello world
/*output: ....
          .
          .-..
          .-..
          ---
        
          .--
          ---
          .-.
          .-..
          -.. */

If we were to type in hello world with any upper case letters we'd get an expected exception. This is because the methods are all case sensitive, meaning you can have a different morse representation for 'a' and 'A' respectively.

//input Hello World
//Wrong input: Error: cannot convert text into morse-representation because there are characters that were not defined yet

More documentation follows later...

Known issues

  • Some documentations are not correct/missing.
  • Inconsistent use of alphabet lookup/not clear what methods only use the internal MorseCharCollection and what methods also use the alphabet.
  • Unit tests done for:
    • MorseCodeTranslator
    • MorseChar
    • MorseCharCollection
Product Compatible and additional computed target framework versions.
.NET Framework net472 is compatible.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.7.2

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.2.0 104 5/20/2024
1.1.1 375 2/2/2024
1.1.0 380 1/27/2024
1.0.2.4 404 1/21/2024
1.0.2.3 432 1/20/2024
1.0.2.2 396 1/20/2024
1.0.2.1 370 1/20/2024

Fixed some bugs relating MorseCodeTranslator and convertions