top of page

As a fun little experiment I decided to make a Morse-code translator in Unreal Engine.

My
goals for it were very simple;
1. It had to take a string of text, translate it and do the sounds correctly. It also shouldn't break when there are characters that don't have a Morse Translation
2. You need to be able to input a string of Morse Code without a lot of extra formatting and get a string of text back.

A quick showcase of it working in Engine

Text to Morse Code

Translating a string of text to Morse Code is actually quite straight forward. I created a map for mapping each letter to their Morse Code translation, including a space. It then loops over the array of characters in the given string and creates a Morse Code sentence out of it. The result of which can be seen down below.
For clarity during reading there is a space between each set of characters in Morse and also '/' to indicate space between words.

Morse Code to Text

Translating a string of Morse back to text is a little more involved as you need you to figure where 1 letter stops and the next one starts. To solve this I simply search for the first space in the sentence from the start and treat the part to left as 1 character. It then chops of the translated part and treats the leftover string as a new string.
This  repeats until the string is empty and which means it's completely translated.
This method is quite simple to implement but does
require that the string is inputted correctly as it won't find the characters otherwise.

bottom of page